Skip to content

Conversation

@jialuoo
Copy link
Contributor

@jialuoo jialuoo commented Dec 4, 2025

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 b/447388852 🦕

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. labels Dec 4, 2025
@jialuoo jialuoo requested a review from chelsea-lin January 8, 2026 20:50
@jialuoo jialuoo self-assigned this Jan 8, 2026
@jialuoo jialuoo marked this pull request as ready for review January 8, 2026 20:51
@jialuoo jialuoo requested review from a team as code owners January 8, 2026 20:51
to=sge.DataType.build("INT64"),
),
),
to=_dtype_to_sql_string(y.dtype), # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

we can call sqlglot_types.from_bigframes_dtype instead and remove "# type: igore"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah better.

this=first, to=sge.DataType.build("BIGNUMERIC")
),
),
to=sge.DataType.build("INT64"),
Copy link
Contributor

Choose a reason for hiding this comment

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

to="INT64" works too and can simple the expression a little bit. If so, can we apply to all the "to" parameter of the "sge.Cast" method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it works.

@jialuoo jialuoo requested review from chelsea-lin and sycai January 9, 2026 20:19
Comment on lines +483 to +511
us = n * 7 * 24 * 60 * 60 * 1000000
first = sge.func(
"UNIX_MICROS",
sge.Add(
this=sge.TimestampTrunc(
this=sge.Cast(this=y.expr, to="TIMESTAMP"),
unit=sge.Var(this="WEEK(MONDAY)"),
),
expression=sge.Interval(
this=sge.convert(6), unit=sge.Identifier(this="DAY")
),
),
)
x_label = sge.Cast(
this=sge.func(
"TIMESTAMP_MICROS",
sge.Cast(
this=sge.Add(
this=sge.Mul(
this=sge.Cast(this=x.expr, to="BIGNUMERIC"),
expression=sge.convert(us),
),
expression=sge.Cast(this=first, to="BIGNUMERIC"),
),
to="INT64",
),
),
to=sqlglot_types.from_bigframes_dtype(y.dtype),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: could we define separate helper functions to handle different frequencies? This would help reduce the size of the function _integer_label_to_datetime_op_non_fixed_frequency and improve readability.

The improved function should look like this

def _integer_label_to_datetime_op_non_fixed_frequency():
    ....
    if rule_code is weekly:
        return _integer_label_to_datetime_op_weekly_freq()
    elif rule_code is monthly:
         ....

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: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants