forked from tobymao/sqlglot
-
Notifications
You must be signed in to change notification settings - Fork 0
Sync upstream up to version 27.1.0 #2
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
431 commits
Select commit
Hold shift + click to select a range
6910744
chore!: update py03 version (#5136)
benfdking a56deab
Chore!: bump sqlglotrs to 0.5.0
georgesittas 305c09b
docs: update API docs, CHANGELOG.md for v26.23.0 [skip ci]
georgesittas a3fccd9
fix(snowflake): generate SELECT for UNNEST without JOIN or FROM (#5138)
geooo109 e164b96
Minor styling updates
georgesittas bb4f428
Feat: bubble up comments nested under a Bracket, fixes #5131
georgesittas 993919d
fix(snowflake): Properly transpile ARRAY_AGG, IGNORE/RESPECT NULLS (#…
VaggelisD 6e57619
fix(snowflake): Transpile ISOWEEK to WEEKISO (#5139)
VaggelisD c484ca3
Fix(bigquery)!: recognize ARRAY_CONCAT_AGG as an aggregate function (…
georgesittas 9f318eb
feat(snowflake): Transpile BQ's `ARRAY(SELECT AS STRUCT ...)` (#5140)
VaggelisD 823f83d
docs: update API docs, CHANGELOG.md for v26.24.0 [skip ci]
georgesittas f3aeb37
Fix(tsql): properly parse and generate ALTER SET (#5143)
georgesittas 72ce404
Fix!: Refactor ALTER TABLE ADD parsing (#5144)
VaggelisD e73ddb7
Fix(mysql)!: preserve TIMESTAMP on roundtrip (#5145)
georgesittas 5752a87
chore: udpate benchmarking framework (#5146)
benfdking 4f8c73d
Fix(hive): STRUCT column names and data type should be separated by '…
tsamaras 93b402a
feat(parser): support SELECT, FROM, WHERE with pipe syntax (#5128)
geooo109 e2a488f
fix: Error on columns mismatch in pushdown_projections ignores dialec…
snovik75 0ae297a
Chore: compare performance on main vs pr branch (#5149)
georgesittas 180963b
Chore: handle pipe syntax unsupported operators more gracefully
georgesittas 6c8d61a
Chore: include optimization benchmarks (#5152)
georgesittas 1a8e78b
feat(parser): ORDER BY with pipe syntax (#5153)
geooo109 e3f41bb
Trim changelog (#5156)
georgesittas 966ad95
feat(tsql): add convert style 126 (#5157)
pa1ch 896bcb5
Add T-SQL test that covers CONVERT code 126
georgesittas 1a35365
Fix: avoid generating nested comments when not supported (#5158)
georgesittas b7ac6ff
feat(parser): LIMIT/OFFSET pipe syntax (#5159)
geooo109 f6124c6
Fix(rust-tokenizer)!: return token vector in `tokenize` even on failu…
georgesittas bc5c66c
Chore: Run benchmark job if /benchmark comment (#5164)
VaggelisD 742b2b7
Chore: Fix benchmark CI to include issue number (#5166)
VaggelisD cfc158d
feat(snowflake): transpile STRTOK_TO_ARRAY to duckdb (#5165)
geooo109 ff0f30b
feat: support ARRAY_REMOVE (#5163)
geooo109 9cac01f
feat(tsql): support FOR XML syntax (#5167)
geooo109 86c6b90
refactor(tsql): XML_OPTIONS
geooo109 760a606
fix(postgres): support decimal values in INTERVAL expressions fixes #…
georgesittas 64c37f1
Chore!: bump sqlglotrs to 0.6.0
georgesittas fd8c088
docs: update API docs, CHANGELOG.md for v26.25.0 [skip ci]
georgesittas 440590b
Chore: bump sqlglotrs to 0.6.1
georgesittas ddcd59b
docs: update API docs, CHANGELOG.md for v26.25.1 [skip ci]
georgesittas 8b5129f
Feat(postgres): improve pretty-formatting of ARRAY[...]
georgesittas f94e0b7
docs: update API docs, CHANGELOG.md for v26.25.2 [skip ci]
georgesittas 964b4a1
Feat: add line/col position for Star
georgesittas 546baed
docs: update API docs, CHANGELOG.md for v26.25.3 [skip ci]
georgesittas 434c45b
Feat!: improve support for ENDSWITH closes #5170
georgesittas 63f9cb4
Feat(sqlglotrs): match the Python implementation of __repr__ for toke…
georgesittas c007afa
Feat: support Star instance as first arg of exp.column helper (#5177)
georgesittas 83de4e1
Chore: improve benchmark result displaying (#5176)
georgesittas bc001ce
feat(postgres)!: Add support for ANY_VALUE for versions 16+ (#5179)
VaggelisD 6a2cb39
fix(parser)!: virtual column with AS(expr) as ComputedColumnConstrain…
geooo109 ba05ff6
feat(parser): AGGREGATE with GROUP AND ORDER BY pipe syntax (#5171)
geooo109 c78d475
used by dlt (#5181)
zilto 26077a4
Feat: make to_table more lenient (#5183)
georgesittas c87ae02
fix(sqlite): Add REPLACE to command tokens (#5192)
VaggelisD 29e2f1d
feat!: Array_intersection transpilation support (#5186)
HarishRavi96 d86a114
feat(sqlite): implement RESPECT/IGNORE NULLS in first_value() (#5185)
NickCrews 5d5dc2f
chore: Clean up exp.ArrayIntersect PR (#5193)
VaggelisD 4b89afd
fix(starrocks): array_agg_transpilation_fix (#5190)
Swathiraj23 1d50fca
Feat: improve transpilation of st_point and st_distance (#5194)
georgesittas 461b054
Fix(postgres): support use_spheroid argument in ST_DISTANCE
georgesittas 756ec3b
feat(parser): SET OPERATORS with pipe syntax (#5184)
geooo109 696150d
docs: update API docs, CHANGELOG.md for v26.26.0 [skip ci]
georgesittas 99bbae3
Fix(sqlite): allow ALTER RENAME without COLUMN keyword fixes #5195
georgesittas ac6555b
Fix(hive)!: preserve DIV binary operator, fixes #5198 (#5199)
georgesittas d0eeb26
fix: eliminate_join_marks has multiple issues fixes #5188 (#5189)
snovik75 ad8a4e7
Chore: refactor join mark elimination to use is_correlated_subquery
georgesittas dfdd84b
fix(parser)!: CTEs instead of subqueries for pipe syntax (#5205)
geooo109 c20f85e
Feat(spark): support ALTER ADD PARTITION (#5208)
georgesittas 77e9d9a
Fix(mysql): properly parse STORED/VIRTUAL computed columns (#5210)
georgesittas 5f95299
Fix(parser)!: support multi-part (>3) dotted functions (#5211)
georgesittas 02afa2a
fix(postgres)!: Preserve quoting for UDT (#5216)
VaggelisD f37c0b1
Fix(snowflake): ensure a standalone GET() expression can be parsed (#…
georgesittas c4debc0
docs: update API docs, CHANGELOG.md for v26.27.0 [skip ci]
georgesittas 9dbcf7a
Dummy commit
georgesittas ca0edce
docs: update API docs, CHANGELOG.md for v26.28.0 [skip ci]
georgesittas 44297f1
feat(parser)!: JOIN pipe syntax, Set Operators as CTEs (#5215)
geooo109 28fed58
Fix(optimizer): UnboundLocalError in scope module
georgesittas aac70aa
refactor(parser): simpler _parse_pipe_syntax_select
geooo109 21cd3eb
feat(parser): PIVOT/UNPIVOT pipe syntax (#5222)
geooo109 809e05a
Fix(snowflake): preserve STRTOK_TO_ARRAY roundtrip
georgesittas 1dab9e2
docs: update API docs, CHANGELOG.md for v26.28.1 [skip ci]
georgesittas 97f5822
feat(parser): AS pipe syntax (#5224)
geooo109 a7e7fee
feat(parser): EXTEND pipe syntax (#5225)
geooo109 c1cb9f8
Feat(snowflake): add autoincrement order clause support (#5223)
dmaresma df73a79
fix(tsql): Retain limit clause in subquery expression. (#5227)
MarcusRisanger 7d966e6
Clean up ORDER/NOORDER snowflake clause
georgesittas 4f42d95
fix(duckdb)!: Normalize date parts in `exp.Extract` generation (#5229)
VaggelisD 91afe4c
feat(parser): TABLESAMPLE pipe syntax (#5231)
geooo109 1b4c083
Fix(athena): include Hive string escapes in the tokenizer (#5233)
georgesittas e7e38fe
Fix(optimizer)!: resolve table "columns" in bigquery that produce str…
georgesittas 781539d
Fix(duckdb): Generate correct DETACH syntax if IF EXISTS is set (#5235)
erindru 62da84a
Feat(snowflake): improve transpilation of unnested object lookup (#5234)
georgesittas 2c60453
feat(parser): DROP pipe syntax (#5226)
geooo109 9885729
feat(parser): SET pipe syntax (#5236)
geooo109 7dfb578
Chore: Refactor DETACH generation (#5237)
VaggelisD ac03639
docs: update API docs, CHANGELOG.md for v26.29.0 [skip ci]
georgesittas d3dc761
Fix!: change comma to cross join when precedence is the same for all …
georgesittas e7c217e
feat(oracle)!: transpile from/to dbms_random.value (#5242)
georgesittas 0d19544
feat: add Microsoft Fabric dialect, a case sensitive version of TSQL …
mattiasthalen 249dbc9
feat(parser): start with SELECT and nested pipe syntax (#5248)
geooo109 f5b5b93
feat(fabric): implement type mappings for unsupported Fabric types (#…
mattiasthalen 78fcea1
feat(spark, databricks): parse brackets as placeholder (#5256)
geooo109 31814cd
Fix(presto)!: cast constructed timestamp literal to zone-aware type i…
georgesittas 7d71387
feat(fabric): Add precision cap to temporal data types (#5250)
mattiasthalen e8cf793
feat(duckdb): Transpile Snowflake's TO_CHAR if format is in Snowflake…
VaggelisD df6fc87
docs: update API docs, CHANGELOG.md for v26.30.0 [skip ci]
georgesittas 847248d
Fix: format ADD CONSTRAINT clause properly fixes #5260
georgesittas db4e0ec
fix(tsql)!: convert information schema keywords to uppercase for cons…
mattiasthalen 0cdfe64
feat: add Exasol dialect (pass 1: string type mapping) (#5264)
nnamdi16 784713a
Clean up Exasol 1st pass
georgesittas e76bba2
Update dialect count
georgesittas 08252c2
Clean up Fabric tests
georgesittas 8de87e3
fix(redshift): handle scale parameter in to_timestamp (#5266)
MatiasCasaliSplit eea1570
Feat(tsql)!: add support for SYSDATETIMEOFFSET closes #5272 (#5273)
georgesittas 3d3ccc5
feat(hive)!: Transpile exp.PosExplode pos column alias (#5274)
VaggelisD e32f709
fix(hive): Fix exp.PosExplode alias order (#5279)
VaggelisD dbc5e9b
Revert "feat(duckdb): Transpile Snowflake's TO_CHAR if format is in S…
georgesittas 3dd9f8e
fix(fabric): Type mismatches and precision error (#5280)
mattiasthalen 1c48c09
feat(exasol): added datatype mappings and test for exasol dialect. (#…
nnamdi16 79d718e
Cleanup
georgesittas 9a95af1
Fix(snowflake)!: only cast strings to timestamp for TO_CHAR (TimeToSt…
georgesittas 883fcb1
feat(databricks): GROUP_CONCAT to LISTAGG (#5284)
geooo109 8af4790
fix(tsql)!: Fix parsing of ADD CONSTRAINT (#5288)
VaggelisD 18aea08
Fix(scope)!: include bigquery unnest aliases in selected sources (#5285)
georgesittas 21ef897
feat(fabric): implement UnixToTime transformation to DATEADD syntax (…
mattiasthalen 57c0e5d
Clean up Fabric UnixToTime generation logic
georgesittas 0ff95c5
Feat!: add parsing/transpilation support for the REPLACE function (#5…
rahulj51 aa5f806
Clean up REPLACE implementation
georgesittas ba4a234
fix(fabric): ignore Date cap (#5290)
fresioAS dc03649
Fix(bigquery)!: only coerce time var -like units into strings for DAT…
georgesittas 1b0631c
feat(exasol): implemented the Mod function (#5292)
nnamdi16 7c63b56
docs: update API docs, CHANGELOG.md for v26.31.0 [skip ci]
georgesittas 5724538
fix(bigquery)!: ARRAY_CONCAT type annotation (#5293)
geooo109 ba7bf39
feat(exasol): implemented BIT_AND function with test (#5294)
nnamdi16 fb4122e
feat(exasol): add bitwiseOr function to exasol dialect (#5297)
nnamdi16 c103b23
feat!: add support for `SUBSTRING_INDEX` (#5296)
ankur334 ca873a1
Fix test
georgesittas 4752f3a
feat(exasol): added bit_xor built in exasol function to exasol dialec…
nnamdi16 09bd610
feat(parser): annotate type of ARRAY_CONCAT_AGG (#5299)
geooo109 ad0311a
feat(exasol): added bit_not exasol built in function. (#5300)
nnamdi16 a7bd823
feat(parser)!: annotate type of ARRAY_TO_STRING (#5301)
geooo109 2aa2182
feat(exasol): added BIT_LSHIFT built in function to exasol dialect (#…
nnamdi16 c3d9ef2
feat(exasol): added the bit_rshift built in exasol function (#5304)
nnamdi16 6b42353
feat(parser)!: annotate type of ARRAY_FIRST, ARRAY_LAST (#5303)
geooo109 f5b7cc6
feat(exasol): added `EVERY` built in function (#5305)
nnamdi16 d3f04d6
feat: add Dremio dialect (#5277)
mateuszpoleski f457b24
Get rid of function name normalization/preservation flags for Dremio
georgesittas 3d8e478
feat(exasol): added edit_distance built in function to exasol dialect…
nnamdi16 db9b61e
feat(parser)!: parse, annotate type for ARRAY_REVERSE (#5306)
geooo109 5612a6d
feat!: add support for SPACE (#5308)
ankur334 ebd8450
Rename _space_sql to space_sql
georgesittas f148c9e
feat(duckdb): Transpile Spark's `exp.PosExplode` (#5311)
VaggelisD 179a278
feat(exasol): added the regexp_replace function (#5313)
nnamdi16 8a2f65d
feat(parser)!: parse and annotate type for ARRAY_SLICE (#5312)
geooo109 8d118ea
Refactor(athena)!: route statements to hive/trino depending on their …
georgesittas d2f7c41
feat!: add TypeOf / toTypeName support (#5315)
ankur334 0a6afcd
Fix: use re-entrant lock in dialects/__init__ to avoid deadlocks (#5322)
georgesittas 599ca81
fix(parser): avoid CTE values ALIAS gen, when ALIAS exists (#5323)
geooo109 cd5c171
Update dialect count
georgesittas 296c15d
docs: update API docs, CHANGELOG.md for v26.33.0 [skip ci]
georgesittas 5a0f589
fix(spark)!: distinguish STORED AS from USING (#5320)
geooo109 cbc79c2
Fix: preserve ORDER BY comments fixes #5326
georgesittas fa69583
fix(optimizer): avoid qualifying CTE (#5327)
geooo109 950c15d
feat(exasol): add var_pop built in function to exasol dialect (#5328)
nnamdi16 c4ca182
feat(optimizer)!: annotate type for FROM_BASE64 (#5329)
geooo109 0992e99
feat(exasol): Add support APPROXIMATE_COUNT_DISTINCT functions in ex…
nnamdi16 7b72bbe
feat(optimizer)!: annotate type for ANY_VALUE (#5331)
geooo109 c0d57e7
feat(optimizer)!: annotate type for CHR (#5332)
geooo109 d65b5c2
feat(optimizer)!: annotate type for COUNTIF (#5334)
geooo109 521b705
feat(optimizer)!: annotate type for GENERATE_ARRAY (#5335)
geooo109 5fb26c5
feat(optimizer)!: annotate type for INT64 (#5339)
geooo109 cff9b55
feat(optimizer)!: annotate type for LOGICAL_AND and LOGICAL_OR (#5340)
geooo109 b94a6f9
feat(optimizer)!: annotate type for MAKE_INTERVAL (#5341)
geooo109 2c9a7c6
feat(optimizer)!: annotate type for LAST_VALUE (#5336)
geooo109 29cce43
fix: comment lost before GROUP, JOIN and HAVING (#5338)
chiiips d862a28
feat(optimizer)!: annoate type for TO_BASE64 (#5342)
geooo109 85888c1
feat(optimizer)!: annotate type for UNIX_DATE (#5343)
geooo109 8a214e0
feat(optimizer)!: annotate type for UNIX_SECONDS (#5344)
geooo109 625cb74
feat(optimizer)!: annotate type for STARTS_WITH (#5345)
geooo109 0337c4d
feat(optimizer)!: annotate type for SHA and SHA2 (#5346)
geooo109 cc389fa
chore(optimizer)!: annotate type SHA1, SHA256, SHA512 for BigQuery (#…
geooo109 835d9e6
Feat: add case-insensitive uppercase normalization strategy (#5349)
georgesittas f80493e
feat(exasol): Add TO_CHAR function support in exasol dialect (#5350)
nnamdi16 194850a
Chore(exasol): clean up TO_CHAR
georgesittas 509b741
Fix!: preserve multi-arg DECODE function instead of converting to CAS…
georgesittas cea6a24
Feat(teradata): add FORMAT phrase parsing (#5348)
readjfb eeddeae
Clean up Teradata FORMAT phrase logic
georgesittas eae64e1
Feat(duckdb): support new lambda syntax (#5359)
georgesittas e77991d
feat(duckdb): Add support for SET VARIABLE (#5360)
VaggelisD 188d446
fix(optimizer): downstream column for PIVOT (#5363)
geooo109 c1d3d61
feat(optimizer)!: annotate type for CORR (#5364)
geooo109 c1e8677
feat(optimizer)!: annotate type for COVAR_POP (#5365)
geooo109 e110ef4
feat(optimizer)!: annotate type for COVAR_SAMP (#5367)
geooo109 5b59c16
feat(optimizer)!: annotate type for DATETIME (#5369)
geooo109 47176ce
feat(optimizer)!: annotate type for ENDS_WITH (#5370)
geooo109 1fd757e
feat(fabric): Ensure TIMESTAMPTZ is used with AT TIME ZONE (#5362)
mattiasthalen 800a82c
Cleanup fabric tests
georgesittas 2cce53d
feat(optimizer)!: annotate type for LAG (#5371)
geooo109 a3227de
Feat!: improve transpilation of `ROUND(x, y)` to Postgres (#5368)
blecourt-private e705e8e
Clean up Postgres ROUND logic
georgesittas 1abd461
Chore: bump min. supported version to python 3.9 (#5353)
georgesittas debd616
docs: update API docs, CHANGELOG.md for v27.0.0 [skip ci]
georgesittas d7ccb48
fix(duckdb)!: week/quarter support (#5374)
eakmanrq b368fba
feat(optimizer)!: parse and annotate type for ASCII (#5377)
geooo109 71b1349
chore(postgres, hive): use ASCII node instead of UNICODE node (#5380)
geooo109 7f19b31
feat(optimizer)!: annotate type for UNICODE (#5381)
geooo109 f035bf0
feat(dremio): Add TIME_MAPPING for Dremio dialect (#5378)
mateuszpoleski a5c2245
Chore: improve error msg for PIVOT with missing aggregation
georgesittas 252469d
fix(snowflake): transpile bigquery CURRENT_DATE with timezone (#5387)
geooo109 7511853
fix(postgres): add XML type (#5396)
geooo109 9e8d3ab
Fix(optimizer)!: Preserve struct-column parentheses for RisingWave di…
MisterWheatley 8f43c5f
Some struct expansion cleanups
georgesittas 31cfd0f
feat(exasol): add to_date and refactored to_char functions with respe…
nnamdi16 3223e63
Fix(fabric)!: cast datetimeoffset to datetime2 (#5385)
mattiasthalen 12b49dd
fix: remove equal sign from CREATE TABLE comment (doris, starrocks) (…
xinge-ji 6709fb9
Add tests for naked table COMMENT property (doris/starrocks)
georgesittas bd3776e
feat(doris): add PROPERTIES_LOCATION mapping for Doris dialect (#5391)
xinge-ji 7eaa67a
Feat(doris): properly supported PROPERTIES and UNIQUE KEY table prop
georgesittas 1e78163
feat(duckdb): support column access via index (#5395)
geooo109 06cea31
fix(postgres)!: support KEY related locks (#5397)
geooo109 1014a67
feat!: remove redundant todate in dayofweek closes #5398 (#5399)
tobymao 92d93a6
Fix(parser): do not consume modifier prefixes in group parser, fixes …
georgesittas be52f78
feat(exasol): add support for CONVERT_TZ function (#5401)
nnamdi16 d637161
feat(exasol): add mapping to TIME_TO_STR in exasol dialect (#5403)
nnamdi16 b2631ae
feat(optimizer)!: annotate type for bigquery BIT_AND, BIT_OR, BIT_XOR…
geooo109 b81ae62
feat(exasol): map STR_TO_TIME to TO_DATE and (#5407)
nnamdi16 c2fb9ab
feat: add `DateStrToTime` (#5409)
betodealmeida ba0c801
fix(tsql): change READ_ONLY to READONLY (#5410)
CrispinStichartFNSB a95993a
Feat(snowflake): improve transpilation of queries with UNNEST sources…
georgesittas 7b69f54
feat(snowflake): Support SEMANTIC_VIEW (#5414)
VaggelisD 7dba6f6
feat(exasol): map AT TIME ZONE to CONVERT_TZ (#5416)
nnamdi16 63da895
fix(risingwave): Fix RisingWave dialect SQL for MAP datatype declarat…
MisterWheatley 25f2c1b
feat(postgres): query placeholders (#5415)
geooo109 c309c87
feat(doris): support range partitioning (#5402)
xinge-ji 2230107
Revert "feat(doris): support range partitioning (#5402)" (#5420)
georgesittas edacae1
fix(snowflake): transpile bigquery GENERATE_DATE_ARRAY with column ac…
geooo109 394d3a8
feat(dremio): Add support for DATE_ADD and DATE_SUB (#5411)
mateuszpoleski 9cfac4f
feat(doris): enhance partitioning support (#5421)
xinge-ji 18c45a2
Clean up Doris partition PR
georgesittas a018bea
feat(exasol): mapped exp.CurrentUser to exasol CURRENT_USER (#5422)
nnamdi16 5835b8d
fix(duckdb)!: make bracket parsing aware of duckdb MAP func (#5423)
geooo109 489dc5c
feat(optimizer)!: parse and annotate type support for JSON_ARRAY (#5424)
geooo109 0ed518c
feat(optimizer)!: annotate type for bigquery JSON_VALUE (#5427)
geooo109 6091617
feat(optimizer)!: annotate type for bigquery JSON_VALUE_ARRAY (#5428)
geooo109 631c851
feat(optimizer)!: parse and annotate type support for bigquery JSON_T…
geooo109 e73bb4d
Fixup
georgesittas 5c59816
fix(snowflake): ALTER TABLE ADD with multiple columns (#5431)
geooo109 6a465be
docs: update API docs, CHANGELOG.md for v27.1.0 [skip ci]
georgesittas 732548f
feat(postgresql): add support for table creation DDL that contains a …
amosbiras 59fd875
Chore: Refactor PRIMARY KEY ... INCLUDE handling (#5433)
VaggelisD 9f860a0
fix(snowflake): ALTER TABLE ADD with IF NOT EXISTS (#5438)
geooo109 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| #!/usr/bin/env python3 | ||
| """Format benchmark comparison output with visual indicators for GitHub markdown.""" | ||
|
|
||
| import re | ||
| import sys | ||
|
|
||
|
|
||
| def format_benchmark_output(content): | ||
| """Add visual formatting to benchmark comparison output.""" | ||
| lines = content.split("\n") | ||
| formatted_lines = [] | ||
|
|
||
| for line in lines: | ||
| # Skip empty lines and headers | ||
| if not line.strip() or line.startswith("|") and "---" in line: | ||
| formatted_lines.append(line) | ||
| continue | ||
|
|
||
| # Process benchmark result lines | ||
| if "|" in line and ("faster" in line or "slower" in line): | ||
| # Extract the speed factor (e.g., "1.23x faster" or "1.10x slower") | ||
| speed_match = re.search(r"(\d+\.\d+)x\s+(faster|slower)", line) | ||
| if speed_match: | ||
| factor = float(speed_match.group(1)) | ||
| direction = speed_match.group(2) | ||
|
|
||
| # Add visual indicators based on performance | ||
| if direction == "faster": | ||
| # Green indicator for faster | ||
| if factor >= 2.0: | ||
| indicator = "🟢🟢" # Double green for 2x+ faster | ||
| elif factor >= 1.1: | ||
| indicator = "🟢" # Single green for 1.1x+ faster | ||
| else: | ||
| indicator = "⚪" # White for marginal improvement | ||
| formatted_text = f"{indicator} **{speed_match.group(0)}**" | ||
| else: | ||
| # Red indicator for slower | ||
| if factor >= 2.0: | ||
| indicator = "🔴🔴" # Double red for 2x+ slower | ||
| elif factor >= 1.1: | ||
| indicator = "🔴" # Single red for 1.1x+ slower | ||
| else: | ||
| indicator = "⚪" # White for marginal slowdown | ||
| formatted_text = f"{indicator} **{speed_match.group(0)}**" | ||
|
|
||
| # Replace the original text with formatted version | ||
| line = line.replace(speed_match.group(0), formatted_text) | ||
| elif "not significant" in line: | ||
| # Add neutral indicator for non-significant changes | ||
| line = re.sub(r"not significant", "⚪ not significant", line) | ||
|
|
||
| formatted_lines.append(line) | ||
|
|
||
| return "\n".join(formatted_lines) | ||
|
|
||
|
|
||
| def main(): | ||
| if len(sys.argv) != 2: | ||
| print("Usage: python format_benchmark.py <input_file>") | ||
| sys.exit(1) | ||
|
|
||
| input_file = sys.argv[1] | ||
|
|
||
| try: | ||
| with open(input_file, "r") as f: | ||
| content = f.read() | ||
|
|
||
| formatted = format_benchmark_output(content) | ||
| print(formatted) | ||
|
|
||
| except FileNotFoundError: | ||
| print(f"Error: File '{input_file}' not found") | ||
| sys.exit(1) | ||
| except Exception as e: | ||
| print(f"Error: {e}") | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
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,91 @@ | ||
| name: Benchmark pull requests | ||
|
|
||
| on: | ||
| issue_comment: | ||
| types: [created, edited, deleted] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| run-benchmark: | ||
| name: run benchmark | ||
| runs-on: ubuntu-latest | ||
| if: | | ||
| (github.event_name == 'issue_comment' && | ||
| contains(github.event.comment.body, '/benchmark') && | ||
| github.event.issue.pull_request) || | ||
| (github.event_name == 'pull_request' && | ||
| contains(github.event.pull_request.body, '/benchmark')) | ||
| steps: | ||
| - name: Checkout PR branch | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # Needed to fetch main branch too | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: 3.13 | ||
| - name: Create a virtual environment | ||
| run: | | ||
| python -m venv .venv | ||
| source ./.venv/bin/activate | ||
| python -m pip install --upgrade pip | ||
| pip install pyperf | ||
| - name: Run benchmark on PR branch | ||
| run: | | ||
| source ./.venv/bin/activate | ||
| make install-dev | ||
| make install-dev-rs-release | ||
| python benchmarks/parse.py --quiet --output bench_parse_pr.json | ||
| python benchmarks/optimize.py --quiet --fast --output bench_optimize_pr.json | ||
| - name: Checkout main branch into subdir | ||
| run: | | ||
| git fetch origin main | ||
| git worktree add main-branch origin/main | ||
| - name: Reset virtual environment | ||
| run: | | ||
| rm -rf .venv | ||
| python -m venv .venv | ||
| source ./.venv/bin/activate | ||
| python -m pip install --upgrade pip | ||
| pip install pyperf | ||
| - name: Run benchmark on main branch | ||
| run: | | ||
| source ./.venv/bin/activate | ||
| cd main-branch | ||
| make install-dev | ||
| make install-dev-rs-release | ||
| python benchmarks/parse.py --quiet --output ../bench_parse_main.json | ||
| python benchmarks/optimize.py --quiet --fast --output ../bench_optimize_main.json | ||
| cd .. | ||
| - name: Compare benchmarks and save results | ||
| run: | | ||
| source ./.venv/bin/activate | ||
| python -m pyperf compare_to bench_parse_main.json bench_parse_pr.json --table --table-format=md > bench_parse_comparison_raw.txt | ||
| python -m pyperf compare_to bench_optimize_main.json bench_optimize_pr.json --table --table-format=md > bench_optimize_comparison_raw.txt | ||
|
|
||
| # Format with colors | ||
| python .github/scripts/format_benchmark.py bench_parse_comparison_raw.txt > bench_parse_comparison.txt | ||
| python .github/scripts/format_benchmark.py bench_optimize_comparison_raw.txt > bench_optimize_comparison.txt | ||
| - name: Combine benchmark outputs | ||
| run: | | ||
| echo "## Benchmark Results" > combined_benchmarks.md | ||
| echo "" >> combined_benchmarks.md | ||
| echo "**Legend:**" >> combined_benchmarks.md | ||
| echo "- 🟢🟢 = 2x+ faster" >> combined_benchmarks.md | ||
| echo "- 🟢 = 1.1x - 2x faster" >> combined_benchmarks.md | ||
| echo "- ⚪ = No significant change (< 1.1x)" >> combined_benchmarks.md | ||
| echo "- 🔴 = 1.1x - 2x slower" >> combined_benchmarks.md | ||
| echo "- 🔴🔴 = 2x+ slower" >> combined_benchmarks.md | ||
| echo "" >> combined_benchmarks.md | ||
| echo "### Parsing Benchmark" >> combined_benchmarks.md | ||
| cat bench_parse_comparison.txt >> combined_benchmarks.md | ||
| echo -e "\n---\n" >> combined_benchmarks.md | ||
| echo "### Optimization Benchmark" >> combined_benchmarks.md | ||
| cat bench_optimize_comparison.txt >> combined_benchmarks.md | ||
| - name: Comment on PR for parse benchmark results | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| issue-number: ${{ github.event.issue.number || github.event.pull_request.number }} | ||
| body-file: combined_benchmarks.md | ||
4 changes: 3 additions & 1 deletion
4
.github/workflows/rust-bench.yml → .github/workflows/benchmark-sqlglotrs.yml
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
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 |
|---|---|---|
|
|
@@ -106,6 +106,7 @@ celerybeat.pid | |
| .venv | ||
| env/ | ||
| venv/ | ||
| venv*/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
Oops, something went wrong.
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.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 6 months ago
To fix the problem, you should add a
permissionsblock to the workflow or to the specific job. The block should specify only the permissions required for the workflow to operate correctly. In this workflow, the main requirement is the ability to read repository contents (contents: read) and to write comments on issues or pull requests (issues: writeand/orpull-requests: write). Since the workflow comments on PRs using thepeter-evans/create-or-update-commentaction, it needs at leastissues: write(for issue comments) andpull-requests: write(for PR comments). To ensure least privilege, add the following block at the job level (underrun-benchmark:):This should be added just beneath the job name (after line 11) in
.github/workflows/benchmark-sqlglot.yml.