MCPcopy Create free account
hub / github.com/rilldata/rill / rewriteSQL

Function rewriteSQL

runtime/drivers/duckdb/model_executor_self.go:514–531  ·  view source on GitHub ↗
(ast *duckdbsql.AST, allFiles []string)

Source from the content-addressed store, hash-verified

512}
513
514func rewriteSQL(ast *duckdbsql.AST, allFiles []string) (string, error) {
515 err := ast.RewriteTableRefs(func(table *duckdbsql.TableRef) (*duckdbsql.TableRef, bool) {
516 return &duckdbsql.TableRef{
517 Paths: allFiles,
518 Function: table.Function,
519 Properties: table.Properties,
520 Params: table.Params,
521 }, true
522 })
523 if err != nil {
524 return "", err
525 }
526 sql, err := ast.Format()
527 if err != nil {
528 return "", err
529 }
530 return sql, nil
531}
532
533// rewriteLocalPaths rewrites a DuckDB SQL statement such that relative paths become absolute paths relative to the basePath,
534// and if allowHostAccess is false, returns an error if any of the paths resolve to a path outside of the basePath.

Callers 1

rewriteDuckDBSQLFunction · 0.85

Calls 2

RewriteTableRefsMethod · 0.80
FormatMethod · 0.65

Tested by

no test coverage detected