refactor: Define sql nodes and transform#2438
Conversation
| @@ -0,0 +1,221 @@ | |||
| # Copyright 2026 Google LLC | |||
There was a problem hiding this comment.
The expression_compiler.py has duplicates codes as the scalar_compiler.py
| @_compile_node.register | ||
| def compile_sql_select(node: sql_nodes.SelectNode, child: ir.SQLGlotIR): | ||
| sqlglot_ir = child | ||
| if node.sorting is not None: |
There was a problem hiding this comment.
The node.predicates are not compiled here?
| (id.sql, scalar_compiler.scalar_op_compiler.compile_expression(expr)) | ||
| for expr, id in node.assignments | ||
| ) | ||
| return child.project(projected_cols) |
There was a problem hiding this comment.
After this change, Is sqlglot_ir.project (or maybe sqlglot_ir.filter?) not used anymore? If so, can we remove them?
| """Compiles a BigFrameNode according to the request into SQL using SQLGlot.""" | ||
|
|
||
| output_names = tuple((expression.DerefOp(id), id.sql) for id in request.node.ids) | ||
| result_node = nodes.ResultNode( |
There was a problem hiding this comment.
IIUC, the ResultNode shares some functionality and properties with the new SelectNode. Can we refactor them together to reduce code complexity?
bigframes/core/sql_nodes.py
Outdated
|
|
||
|
|
||
| @dataclasses.dataclass(frozen=True, eq=True) | ||
| class ColumnDef: |
There was a problem hiding this comment.
It's not used anywhere because we are using the one defined at the nodes.py file? Also, both this node and ResultNode are both compiled nodes only. Maybe they should be put into one file? Ideally, the node.py file has over 1700 lines and can be break-down into smaller ones.
bigframes/core/sql_nodes.py
Outdated
| import bigframes.dtypes | ||
|
|
||
| # A fixed number of variable to assume for overhead on some operations | ||
| OVERHEAD_VARIABLES = 5 |
There was a problem hiding this comment.
It's not used anywhere?
bigframes/core/rewrite/as_sql.py
Outdated
| @@ -0,0 +1,213 @@ | |||
| # Copyright 2025 Google LLC | |||
There was a problem hiding this comment.
Copyright 2026? Can you please check other files too?
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕