Skip to content

Commit 2393288

Browse files
committed
fix
1 parent 355d02b commit 2393288

File tree

2 files changed

+2
-59
lines changed

2 files changed

+2
-59
lines changed

tests/unit/core/compile/sqlglot/expressions/snapshots/test_datetime_ops/test_datetime_to_integer_label/out.sql

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,6 @@ WITH `bfcte_0` AS (
1212
86400000000
1313
)
1414
) AS INT64) AS `bfcol_2`,
15-
CASE
16-
WHEN (
17-
EXTRACT(YEAR FROM `datetime_col`) * 12 + EXTRACT(MONTH FROM `datetime_col`) - 1
18-
) = (
19-
EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1
20-
)
21-
THEN 0
22-
ELSE CAST(FLOOR(
23-
IEEE_DIVIDE(
24-
(
25-
EXTRACT(YEAR FROM `datetime_col`) * 12 + EXTRACT(MONTH FROM `datetime_col`) - 1
26-
) - (
27-
EXTRACT(YEAR FROM `timestamp_col`) * 12 + EXTRACT(MONTH FROM `timestamp_col`) - 1
28-
) - 1,
29-
1
30-
)
31-
) AS INT64) + 1
32-
END AS `bfcol_3`,
3315
CASE
3416
WHEN UNIX_MICROS(
3517
CAST(TIMESTAMP_TRUNC(`datetime_col`, WEEK(MONDAY)) + INTERVAL 6 DAY AS TIMESTAMP)
@@ -47,38 +29,10 @@ WITH `bfcte_0` AS (
4729
604800000000
4830
)
4931
) AS INT64) + 1
50-
END AS `bfcol_4`,
51-
CASE
52-
WHEN (
53-
EXTRACT(YEAR FROM `datetime_col`) * 4 + EXTRACT(QUARTER FROM `datetime_col`) - 1
54-
) = (
55-
EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1
56-
)
57-
THEN 0
58-
ELSE CAST(FLOOR(
59-
IEEE_DIVIDE(
60-
(
61-
EXTRACT(YEAR FROM `datetime_col`) * 4 + EXTRACT(QUARTER FROM `datetime_col`) - 1
62-
) - (
63-
EXTRACT(YEAR FROM `timestamp_col`) * 4 + EXTRACT(QUARTER FROM `timestamp_col`) - 1
64-
) - 1,
65-
1
66-
)
67-
) AS INT64) + 1
68-
END AS `bfcol_5`,
69-
CASE
70-
WHEN EXTRACT(YEAR FROM `datetime_col`) = EXTRACT(YEAR FROM `timestamp_col`)
71-
THEN 0
72-
ELSE CAST(FLOOR(
73-
IEEE_DIVIDE(EXTRACT(YEAR FROM `datetime_col`) - EXTRACT(YEAR FROM `timestamp_col`) - 1, 1)
74-
) AS INT64) + 1
75-
END AS `bfcol_6`
32+
END AS `bfcol_3`
7633
FROM `bfcte_0`
7734
)
7835
SELECT
7936
`bfcol_2` AS `fixed_freq`,
80-
`bfcol_3` AS `non_fixed_freq_monthly`,
81-
`bfcol_4` AS `non_fixed_freq_weekly`,
82-
`bfcol_5` AS `non_fixed_freq_quarterly`,
83-
`bfcol_6` AS `non_fixed_freq_yearly`
37+
`bfcol_3` AS `non_fixed_freq_weekly`
8438
FROM `bfcte_1`

tests/unit/core/compile/sqlglot/expressions/test_datetime_ops.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,9 @@ def test_datetime_to_integer_label(scalar_types_df: bpd.DataFrame, snapshot):
6464
"fixed_freq": ops.DatetimeToIntegerLabelOp(
6565
freq=pd.tseries.offsets.Day(), origin="start", closed="left" # type: ignore
6666
).as_expr("datetime_col", "timestamp_col"),
67-
"non_fixed_freq_monthly": ops.DatetimeToIntegerLabelOp(
68-
freq=pd.tseries.offsets.MonthEnd(), origin="start", closed="left" # type: ignore
69-
).as_expr("datetime_col", "timestamp_col"),
7067
"non_fixed_freq_weekly": ops.DatetimeToIntegerLabelOp(
7168
freq=pd.tseries.offsets.Week(weekday=6), origin="start", closed="left" # type: ignore
7269
).as_expr("datetime_col", "timestamp_col"),
73-
"non_fixed_freq_quarterly": ops.DatetimeToIntegerLabelOp(
74-
freq=pd.tseries.offsets.QuarterEnd(startingMonth=12), # type: ignore
75-
origin="start",
76-
closed="left",
77-
).as_expr("datetime_col", "timestamp_col"),
78-
"non_fixed_freq_yearly": ops.DatetimeToIntegerLabelOp(
79-
freq=pd.tseries.offsets.YearEnd(month=12), origin="start", closed="left" # type: ignore
80-
).as_expr("datetime_col", "timestamp_col"),
8170
}
8271

8372
sql = utils._apply_ops_to_sql(bf_df, list(ops_map.values()), list(ops_map.keys()))

0 commit comments

Comments
 (0)