-
Notifications
You must be signed in to change notification settings - Fork 57
chore: implement add_op and del_op compilers #1955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
db867d3
chore: implement add_op and del_op compilers
chelsea-lin f2c80bb
add sub_op implementations
chelsea-lin 3074a1f
add more unit-tests
chelsea-lin 5229ec5
Merge branch 'main' into main_chelsealin_add
chelsea-lin 7bcdffd
Merge branch 'main' into main_chelsealin_add
chelsea-lin 379745c
Merge branch 'main' into main_chelsealin_add
chelsea-lin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 45 additions & 4 deletions
49
.../core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric/out.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,54 @@ | ||
WITH `bfcte_0` AS ( | ||
SELECT | ||
`int64_col` AS `bfcol_0` | ||
`bool_col` AS `bfcol_0`, | ||
`int64_col` AS `bfcol_1`, | ||
`rowindex` AS `bfcol_2` | ||
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` | ||
), `bfcte_1` AS ( | ||
SELECT | ||
*, | ||
`bfcol_0` + `bfcol_0` AS `bfcol_1` | ||
`bfcol_2` AS `bfcol_6`, | ||
`bfcol_1` AS `bfcol_7`, | ||
`bfcol_0` AS `bfcol_8`, | ||
`bfcol_1` + `bfcol_1` AS `bfcol_9` | ||
FROM `bfcte_0` | ||
), `bfcte_2` AS ( | ||
SELECT | ||
*, | ||
`bfcol_6` AS `bfcol_14`, | ||
`bfcol_7` AS `bfcol_15`, | ||
`bfcol_8` AS `bfcol_16`, | ||
`bfcol_9` AS `bfcol_17`, | ||
`bfcol_7` + 1 AS `bfcol_18` | ||
FROM `bfcte_1` | ||
), `bfcte_3` AS ( | ||
SELECT | ||
*, | ||
`bfcol_14` AS `bfcol_24`, | ||
`bfcol_15` AS `bfcol_25`, | ||
`bfcol_16` AS `bfcol_26`, | ||
`bfcol_17` AS `bfcol_27`, | ||
`bfcol_18` AS `bfcol_28`, | ||
`bfcol_15` + CAST(`bfcol_16` AS INT64) AS `bfcol_29` | ||
FROM `bfcte_2` | ||
), `bfcte_4` AS ( | ||
SELECT | ||
*, | ||
`bfcol_24` AS `bfcol_36`, | ||
`bfcol_25` AS `bfcol_37`, | ||
`bfcol_26` AS `bfcol_38`, | ||
`bfcol_27` AS `bfcol_39`, | ||
`bfcol_28` AS `bfcol_40`, | ||
`bfcol_29` AS `bfcol_41`, | ||
CAST(`bfcol_26` AS INT64) + `bfcol_25` AS `bfcol_42` | ||
FROM `bfcte_3` | ||
) | ||
SELECT | ||
`bfcol_1` AS `int64_col` | ||
FROM `bfcte_1` | ||
`bfcol_36` AS `rowindex`, | ||
`bfcol_37` AS `int64_col`, | ||
`bfcol_38` AS `bool_col`, | ||
`bfcol_39` AS `int_add_int`, | ||
`bfcol_40` AS `int_add_1`, | ||
`bfcol_41` AS `int_add_bool`, | ||
`bfcol_42` AS `bool_add_int` | ||
FROM `bfcte_4` |
13 changes: 0 additions & 13 deletions
13
...pile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric_w_scalar/out.sql
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
...ore/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_timedelta/out.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
WITH `bfcte_0` AS ( | ||
SELECT | ||
`date_col` AS `bfcol_0`, | ||
`rowindex` AS `bfcol_1`, | ||
`timestamp_col` AS `bfcol_2` | ||
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` | ||
), `bfcte_1` AS ( | ||
SELECT | ||
*, | ||
`bfcol_1` AS `bfcol_6`, | ||
`bfcol_2` AS `bfcol_7`, | ||
`bfcol_0` AS `bfcol_8`, | ||
TIMESTAMP_ADD(CAST(`bfcol_0` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` | ||
FROM `bfcte_0` | ||
), `bfcte_2` AS ( | ||
SELECT | ||
*, | ||
`bfcol_6` AS `bfcol_14`, | ||
`bfcol_7` AS `bfcol_15`, | ||
`bfcol_8` AS `bfcol_16`, | ||
`bfcol_9` AS `bfcol_17`, | ||
TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` | ||
FROM `bfcte_1` | ||
), `bfcte_3` AS ( | ||
SELECT | ||
*, | ||
`bfcol_14` AS `bfcol_24`, | ||
`bfcol_15` AS `bfcol_25`, | ||
`bfcol_16` AS `bfcol_26`, | ||
`bfcol_17` AS `bfcol_27`, | ||
`bfcol_18` AS `bfcol_28`, | ||
TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` | ||
FROM `bfcte_2` | ||
), `bfcte_4` AS ( | ||
SELECT | ||
*, | ||
`bfcol_24` AS `bfcol_36`, | ||
`bfcol_25` AS `bfcol_37`, | ||
`bfcol_26` AS `bfcol_38`, | ||
`bfcol_27` AS `bfcol_39`, | ||
`bfcol_28` AS `bfcol_40`, | ||
`bfcol_29` AS `bfcol_41`, | ||
TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` | ||
FROM `bfcte_3` | ||
), `bfcte_5` AS ( | ||
SELECT | ||
*, | ||
172800000000 AS `bfcol_50` | ||
FROM `bfcte_4` | ||
) | ||
SELECT | ||
`bfcol_36` AS `rowindex`, | ||
`bfcol_37` AS `timestamp_col`, | ||
`bfcol_38` AS `date_col`, | ||
`bfcol_39` AS `date_add_timedelta`, | ||
`bfcol_40` AS `timestamp_add_timedelta`, | ||
`bfcol_41` AS `timedelta_add_date`, | ||
`bfcol_42` AS `timedelta_add_timestamp`, | ||
`bfcol_50` AS `timedelta_add_timedelta` | ||
FROM `bfcte_5` |
54 changes: 54 additions & 0 deletions
54
.../core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_numeric/out.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
WITH `bfcte_0` AS ( | ||
SELECT | ||
`bool_col` AS `bfcol_0`, | ||
`int64_col` AS `bfcol_1`, | ||
`rowindex` AS `bfcol_2` | ||
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` | ||
), `bfcte_1` AS ( | ||
SELECT | ||
*, | ||
`bfcol_2` AS `bfcol_6`, | ||
`bfcol_1` AS `bfcol_7`, | ||
`bfcol_0` AS `bfcol_8`, | ||
`bfcol_1` - `bfcol_1` AS `bfcol_9` | ||
FROM `bfcte_0` | ||
), `bfcte_2` AS ( | ||
SELECT | ||
*, | ||
`bfcol_6` AS `bfcol_14`, | ||
`bfcol_7` AS `bfcol_15`, | ||
`bfcol_8` AS `bfcol_16`, | ||
`bfcol_9` AS `bfcol_17`, | ||
`bfcol_7` - 1 AS `bfcol_18` | ||
FROM `bfcte_1` | ||
), `bfcte_3` AS ( | ||
SELECT | ||
*, | ||
`bfcol_14` AS `bfcol_24`, | ||
`bfcol_15` AS `bfcol_25`, | ||
`bfcol_16` AS `bfcol_26`, | ||
`bfcol_17` AS `bfcol_27`, | ||
`bfcol_18` AS `bfcol_28`, | ||
`bfcol_15` - CAST(`bfcol_16` AS INT64) AS `bfcol_29` | ||
FROM `bfcte_2` | ||
), `bfcte_4` AS ( | ||
SELECT | ||
*, | ||
`bfcol_24` AS `bfcol_36`, | ||
`bfcol_25` AS `bfcol_37`, | ||
`bfcol_26` AS `bfcol_38`, | ||
`bfcol_27` AS `bfcol_39`, | ||
`bfcol_28` AS `bfcol_40`, | ||
`bfcol_29` AS `bfcol_41`, | ||
CAST(`bfcol_26` AS INT64) - `bfcol_25` AS `bfcol_42` | ||
FROM `bfcte_3` | ||
) | ||
SELECT | ||
`bfcol_36` AS `rowindex`, | ||
`bfcol_37` AS `int64_col`, | ||
`bfcol_38` AS `bool_col`, | ||
`bfcol_39` AS `int_add_int`, | ||
`bfcol_40` AS `int_add_1`, | ||
`bfcol_41` AS `int_add_bool`, | ||
`bfcol_42` AS `bool_add_int` | ||
FROM `bfcte_4` |
60 changes: 60 additions & 0 deletions
60
...ore/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_timedelta/out.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
WITH `bfcte_0` AS ( | ||
SELECT | ||
`date_col` AS `bfcol_0`, | ||
`rowindex` AS `bfcol_1`, | ||
`timestamp_col` AS `bfcol_2` | ||
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` | ||
), `bfcte_1` AS ( | ||
SELECT | ||
*, | ||
`bfcol_1` AS `bfcol_6`, | ||
`bfcol_2` AS `bfcol_7`, | ||
`bfcol_0` AS `bfcol_8`, | ||
TIMESTAMP_SUB(CAST(`bfcol_0` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` | ||
FROM `bfcte_0` | ||
), `bfcte_2` AS ( | ||
SELECT | ||
*, | ||
`bfcol_6` AS `bfcol_14`, | ||
`bfcol_7` AS `bfcol_15`, | ||
`bfcol_8` AS `bfcol_16`, | ||
`bfcol_9` AS `bfcol_17`, | ||
TIMESTAMP_SUB(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` | ||
FROM `bfcte_1` | ||
), `bfcte_3` AS ( | ||
SELECT | ||
*, | ||
`bfcol_14` AS `bfcol_24`, | ||
`bfcol_15` AS `bfcol_25`, | ||
`bfcol_16` AS `bfcol_26`, | ||
`bfcol_17` AS `bfcol_27`, | ||
`bfcol_18` AS `bfcol_28`, | ||
TIMESTAMP_DIFF(CAST(`bfcol_16` AS DATETIME), CAST(`bfcol_16` AS DATETIME), MICROSECOND) AS `bfcol_29` | ||
FROM `bfcte_2` | ||
), `bfcte_4` AS ( | ||
SELECT | ||
*, | ||
`bfcol_24` AS `bfcol_36`, | ||
`bfcol_25` AS `bfcol_37`, | ||
`bfcol_26` AS `bfcol_38`, | ||
`bfcol_27` AS `bfcol_39`, | ||
`bfcol_28` AS `bfcol_40`, | ||
`bfcol_29` AS `bfcol_41`, | ||
TIMESTAMP_DIFF(`bfcol_25`, `bfcol_25`, MICROSECOND) AS `bfcol_42` | ||
FROM `bfcte_3` | ||
), `bfcte_5` AS ( | ||
SELECT | ||
*, | ||
0 AS `bfcol_50` | ||
FROM `bfcte_4` | ||
) | ||
SELECT | ||
`bfcol_36` AS `rowindex`, | ||
`bfcol_37` AS `timestamp_col`, | ||
`bfcol_38` AS `date_col`, | ||
`bfcol_39` AS `date_sub_timedelta`, | ||
`bfcol_40` AS `timestamp_sub_timedelta`, | ||
`bfcol_41` AS `timestamp_sub_date`, | ||
`bfcol_42` AS `date_sub_timestamp`, | ||
`bfcol_50` AS `timedelta_sub_timedelta` | ||
FROM `bfcte_5` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the boolean subtraction is not allowed either:
python-bigquery-dataframes/bigframes/operations/numeric_ops.py
Lines 201 to 202 in 51057fc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pandas does not allow both ops are bool types but allow one of ops is bool type: https://screenshot.googleplex.com/4Swcj3gUzMw9UWP