Skip to content

Commit

Permalink
chore(sql): regen sql for updated version of sqlglot
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Sep 24, 2023
1 parent e765712 commit 0908253
Show file tree
Hide file tree
Showing 181 changed files with 970 additions and 521 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
SELECT t0.`title`, t0.`tags`
SELECT
t0.`title`,
t0.`tags`
FROM (
SELECT t1.*
FROM `bigquery-public-data.stackoverflow.posts_questions` t1
WHERE STRPOS(t1.`tags`, 'ibis') - 1 >= 0
) t0
SELECT
t1.*
FROM `bigquery-public-data`.stackoverflow.posts_questions AS t1
WHERE
STRPOS(t1.`tags`, 'ibis') - 1 >= 0
) AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT
t0.`title`
FROM `bigquery-public-data`.stackoverflow.posts_questions AS t0
INNER JOIN `nyc-tlc`.yellow.trips AS t1
ON t0.`tags` = t1.`rate_code`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SELECT
t0.`title`
FROM `bigquery-public-data`.stackoverflow.posts_questions AS t0
INNER JOIN `nyc-tlc`.yellow.trips AS t1
ON t0.`tags` = t1.`rate_code`
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
WITH t0 AS (
SELECT t2.`float_col`, t2.`timestamp_col`, t2.`int_col`, t2.`string_col`
FROM `ibis-gbq.ibis_gbq_testing.functional_alltypes` t2
WHERE t2.`timestamp_col` < @param_0
SELECT
t2.`float_col`,
t2.`timestamp_col`,
t2.`int_col`,
t2.`string_col`
FROM `ibis-gbq`.ibis_gbq_testing.functional_alltypes AS t2
WHERE
t2.`timestamp_col` < @param_0
)
SELECT count(t1.`foo`) AS `count`
SELECT
count(t1.`foo`) AS `count`
FROM (
SELECT t0.`string_col`, sum(t0.`float_col`) AS `foo`
SELECT
t0.`string_col`,
sum(t0.`float_col`) AS `foo`
FROM t0
GROUP BY 1
) t1
GROUP BY
1
) AS t1
18 changes: 4 additions & 14 deletions ibis/backends/bigquery/tests/system/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,33 +248,23 @@ def test_exists_table_different_project(con):
assert "foobar" not in con.list_tables(database=database)


def test_multiple_project_queries(con):
def test_multiple_project_queries(con, snapshot):
so = con.table("posts_questions", database="bigquery-public-data.stackoverflow")
trips = con.table("trips", database="nyc-tlc.yellow")
join = so.join(trips, so.tags == trips.rate_code)[[so.title]]
result = join.compile()
expected = """\
SELECT t0.`title`
FROM `bigquery-public-data.stackoverflow.posts_questions` t0
INNER JOIN `nyc-tlc.yellow.trips` t1
ON t0.`tags` = t1.`rate_code`"""
assert result == expected
snapshot.assert_match(result, "out.sql")


def test_multiple_project_queries_database_api(con):
def test_multiple_project_queries_database_api(con, snapshot):
stackoverflow = con.database("bigquery-public-data.stackoverflow")
posts_questions = stackoverflow.posts_questions
yellow = con.database("nyc-tlc.yellow")
trips = yellow.trips
predicate = posts_questions.tags == trips.rate_code
join = posts_questions.join(trips, predicate)[[posts_questions.title]]
result = join.compile()
expected = """\
SELECT t0.`title`
FROM `bigquery-public-data.stackoverflow.posts_questions` t0
INNER JOIN `nyc-tlc.yellow.trips` t1
ON t0.`tags` = t1.`rate_code`"""
assert result == expected
snapshot.assert_match(result, "out.sql")


def test_multiple_project_queries_execute(con):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT APPROX_QUANTILES(if(t0.`month` > 0, t0.`double_col`, NULL), 2)[OFFSET(1)] AS `ApproxMedian_double_col_ Greater_month_ 0`
FROM functional_alltypes t0
SELECT
APPROX_QUANTILES(IF(t0.`month` > 0, t0.`double_col`, NULL), 2)[OFFSET(1)] AS `ApproxMedian_double_col_ Greater_month_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT APPROX_COUNT_DISTINCT(if(t0.`month` > 0, t0.`double_col`, NULL)) AS `ApproxCountDistinct_double_col_ Greater_month_ 0`
FROM functional_alltypes t0
SELECT
APPROX_COUNT_DISTINCT(IF(t0.`month` > 0, t0.`double_col`, NULL)) AS `ApproxCountDistinct_double_col_ Greater_month_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT APPROX_QUANTILES(t0.`double_col`, 2)[OFFSET(1)] AS `ApproxMedian_double_col`
FROM functional_alltypes t0
SELECT
APPROX_QUANTILES(t0.`double_col`, 2)[OFFSET(1)] AS `ApproxMedian_double_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT APPROX_COUNT_DISTINCT(t0.`double_col`) AS `ApproxCountDistinct_double_col`
FROM functional_alltypes t0
SELECT
APPROX_COUNT_DISTINCT(t0.`double_col`) AS `ApproxCountDistinct_double_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT CAST(t0.`value` AS BYTES) AS `Cast_value_ binary`
FROM t t0
SELECT
CAST(t0.`value` AS BYTES) AS `Cast_value_ binary`
FROM t AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_AND(if(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitAnd_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes t0
SELECT
BIT_AND(IF(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitAnd_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_OR(if(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitOr_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes t0
SELECT
BIT_OR(IF(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitOr_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_XOR(if(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitXor_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes t0
SELECT
BIT_XOR(IF(t0.`bigint_col` > 0, t0.`int_col`, NULL)) AS `BitXor_int_col_ Greater_bigint_col_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_AND(t0.`int_col`) AS `BitAnd_int_col`
FROM functional_alltypes t0
SELECT
BIT_AND(t0.`int_col`) AS `BitAnd_int_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_OR(t0.`int_col`) AS `BitOr_int_col`
FROM functional_alltypes t0
SELECT
BIT_OR(t0.`int_col`) AS `BitOr_int_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT BIT_XOR(t0.`int_col`) AS `BitXor_int_col`
FROM functional_alltypes t0
SELECT
BIT_XOR(t0.`int_col`) AS `BitXor_int_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT avg(CAST(t0.`bool_col` AS INT64)) AS `Mean_bool_col`
FROM functional_alltypes t0
SELECT
avg(CAST(t0.`bool_col` AS INT64)) AS `Mean_bool_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT sum(CAST(t0.`bool_col` AS INT64)) AS `Sum_bool_col`
FROM functional_alltypes t0
SELECT
sum(CAST(t0.`bool_col` AS INT64)) AS `Sum_bool_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
SELECT sum(if((t0.`month` > 6) AND (t0.`month` < 10), CAST(t0.`bool_col` AS INT64), NULL)) AS `Sum_bool_col_ And_Greater_month_ 6_ Less_month_ 10`
FROM functional_alltypes t0
SELECT
sum(
IF((
t0.`month` > 6
) AND (
t0.`month` < 10
), CAST(t0.`bool_col` AS INT64), NULL)
) AS `Sum_bool_col_ And_Greater_month_ 6_ Less_month_ 10`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT avg(if(t0.`month` > 6, CAST(t0.`bool_col` AS INT64), NULL)) AS `Mean_bool_col_ Greater_month_ 6`
FROM functional_alltypes t0
SELECT
avg(IF(t0.`month` > 6, CAST(t0.`bool_col` AS INT64), NULL)) AS `Mean_bool_col_ Greater_month_ 6`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
SELECT
CASE
WHEN (0 <= t0.`value`) AND (t0.`value` < 1) THEN 0
WHEN (1 <= t0.`value`) AND (t0.`value` <= 3) THEN 1
WHEN (
0 <= t0.`value`
) AND (
t0.`value` < 1
)
THEN 0
WHEN (
1 <= t0.`value`
) AND (
t0.`value` <= 3
)
THEN 1
ELSE CAST(NULL AS INT64)
END AS `tmp`
FROM t t0
FROM t AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT CAST(TRUNC(t0.`double_col`) AS INT64) AS `Cast_double_col_ int64`
FROM functional_alltypes t0
SELECT
CAST(TRUNC(t0.`double_col`) AS INT64) AS `Cast_double_col_ int64`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT sum(t0.`foo`) AS `Sum_foo`
FROM t0 t0
SELECT
sum(t0.`foo`) AS `Sum_foo`
FROM t0 AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT COVAR_POP(t0.`double_col`, t0.`double_col`) AS `Covariance_double_col_ double_col`
FROM functional_alltypes t0
SELECT
COVAR_POP(t0.`double_col`, t0.`double_col`) AS `Covariance_double_col_ double_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT COVAR_SAMP(t0.`double_col`, t0.`double_col`) AS `Covariance_double_col_ double_col`
FROM functional_alltypes t0
SELECT
COVAR_SAMP(t0.`double_col`, t0.`double_col`) AS `Covariance_double_col_ double_col`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM DATE '2017-01-01') + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01' AS DATE)) + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(DATE '2017-01-01' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
SELECT
INITCAP(CAST(CAST('2017-01-01' AS DATE) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM TIMESTAMP '2017-01-01 04:55:59') + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01 04:55:59' AS TIMESTAMP)) + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(TIMESTAMP '2017-01-01 04:55:59' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
INITCAP(CAST(CAST('2017-01-01 04:55:59' AS TIMESTAMP) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM DATE '2017-01-01') + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01' AS DATE)) + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(DATE '2017-01-01' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
SELECT
INITCAP(CAST(CAST('2017-01-01' AS DATE) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM TIMESTAMP '2017-01-01 04:55:59') + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01 04:55:59' AS TIMESTAMP)) + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(TIMESTAMP '2017-01-01 04:55:59' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
INITCAP(CAST(CAST('2017-01-01 04:55:59' AS TIMESTAMP) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM TIMESTAMP '2017-01-01 04:55:59') + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01 04:55:59' AS TIMESTAMP)) + 5, 7) AS `DayOfWeekIndex_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(TIMESTAMP '2017-01-01 04:55:59' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
SELECT
INITCAP(CAST(CAST('2017-01-01 04:55:59' AS TIMESTAMP) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_datetime_2017_ 1_ 1_ 4_ 55_ 59`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT MOD(EXTRACT(DAYOFWEEK FROM DATE '2017-01-01') + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
SELECT
MOD(EXTRACT(DAYOFWEEK FROM CAST('2017-01-01' AS DATE)) + 5, 7) AS `DayOfWeekIndex_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
SELECT INITCAP(CAST(DATE '2017-01-01' AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
SELECT
INITCAP(CAST(CAST('2017-01-01' AS DATE) AS STRING FORMAT 'DAY')) AS `DayOfWeekName_datetime_date_2017_ 1_ 1`
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT CAST(FLOOR(IEEE_DIVIDE(t0.`double_col`, 0)) AS INT64) AS `FloorDivide_double_col_ 0`
FROM functional_alltypes t0
SELECT
CAST(FLOOR(IEEE_DIVIDE(t0.`double_col`, 0)) AS INT64) AS `FloorDivide_double_col_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT IEEE_DIVIDE(t0.`double_col`, 0) AS `Divide_double_col_ 0`
FROM functional_alltypes t0
SELECT
IEEE_DIVIDE(t0.`double_col`, 0) AS `Divide_double_col_ 0`
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT DATE(t0.`ts`) AS `tmp`
FROM t t0
SELECT
DATE(t0.`ts`) AS `tmp`
FROM t AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT TIME(t0.`ts`) AS `tmp`
FROM t t0
SELECT
TIME(t0.`ts`) AS `tmp`
FROM t AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT ST_AZIMUTH(t0.`p0`, t0.`p1`) AS `tmp`
FROM t t0
SELECT
ST_AZIMUTH(t0.`p0`, t0.`p1`) AS `tmp`
FROM t AS t0
Loading

1 comment on commit 0908253

@ibis-squawk-bot
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 3.

Benchmark suite Current: 0908253 Previous: b37804a Ratio
ibis/tests/benchmarks/test_benchmarks.py::test_compile[large-bigquery] 26.963053983133538 iter/sec (stddev: 0.0005446653036635249) 146.4406797920701 iter/sec (stddev: 0.00006932716190392247) 5.43
ibis/tests/benchmarks/test_benchmarks.py::test_compile[small-sqlite] 84.27751659167761 iter/sec (stddev: 0.026498130177089848) 2515.2382920939253 iter/sec (stddev: 0.00007598471609268787) 29.84
ibis/tests/benchmarks/test_benchmarks.py::test_compile_with_drops[bigquery] 35.57813515606157 iter/sec (stddev: 0.0004347091575534014) 130.02477424437095 iter/sec (stddev: 0.000247510166318326) 3.65
ibis/tests/benchmarks/test_benchmarks.py::test_compile[medium-bigquery] 61.99066769720976 iter/sec (stddev: 0.001082696064210873) 603.5295570002766 iter/sec (stddev: 0.000035398257191080955) 9.74
ibis/tests/benchmarks/test_benchmarks.py::test_compile[small-bigquery] 1420.1135817842894 iter/sec (stddev: 0.00005243620043163661) 10602.847663506958 iter/sec (stddev: 0.00005834248372791223) 7.47

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.