Skip to content

refactor: Define sql nodes and transform#2438

Draft
TrevorBergeron wants to merge 6 commits intomainfrom
compaction_rewriter
Draft

refactor: Define sql nodes and transform#2438
TrevorBergeron wants to merge 6 commits intomainfrom
compaction_rewriter

Conversation

@TrevorBergeron
Copy link
Contributor

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:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Feb 5, 2026
@@ -0,0 +1,221 @@
# Copyright 2026 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, the ResultNode shares some functionality and properties with the new SelectNode. Can we refactor them together to reduce code complexity?



@dataclasses.dataclass(frozen=True, eq=True)
class ColumnDef:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

import bigframes.dtypes

# A fixed number of variable to assume for overhead on some operations
OVERHEAD_VARIABLES = 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not used anywhere?

@@ -0,0 +1,213 @@
# Copyright 2025 Google LLC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright 2026? Can you please check other files too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: xl Pull request size is extra large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants