Skip to content

Commit

Permalink
chore: quote everything (#8172)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Feb 2, 2024
1 parent 77052c7 commit e68000c
Show file tree
Hide file tree
Showing 505 changed files with 4,600 additions and 4,470 deletions.
8 changes: 3 additions & 5 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,9 @@ def connect(resource: Path | str, **kwargs: Any) -> BaseBackend:
Connect to an on-disk SQLite database:
>>> con = ibis.connect("sqlite://relative.db")
>>> con = ibis.connect("sqlite:///absolute/path/to/data.db")
>>> con = ibis.connect(
... "sqlite:///absolute/path/to/data.db"
... ) # quartodoc: +SKIP # doctest: +SKIP
Connect to a PostgreSQL server:
Expand Down Expand Up @@ -1418,10 +1420,6 @@ def connect(resource: Path | str, **kwargs: Any) -> BaseBackend:
# SQLAlchemy requires a `://`, while urllib may roundtrip
# `duckdb://` to `duckdb:`. Here we re-add the missing `//`.
url = url.replace(":", "://", 1)
if scheme in ("duckdb", "sqlite", "pyspark"):
# SQLAlchemy wants an extra slash for URLs where the path
# maps to a relative/absolute location on the filesystem
url = url.replace(":", ":/", 1)

try:
backend = getattr(ibis, scheme)
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/base/sqlglot/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class SQLGlotCompiler(abc.ABC):
no_limit_value: sge.Null | None = None
"""The value to use to indicate no limit."""

quoted: bool | None = None
quoted: bool = True
"""Whether to always quote identifiers."""

NAN: ClassVar[sge.Expression] = sge.Cast(
Expand Down
2 changes: 2 additions & 0 deletions ibis/backends/base/sqlglot/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ def _from_sqlglot_INTERVAL(
else:
unit = precision_or_span.this.this
return dt.Interval(unit=unit, nullable=nullable)
elif isinstance(precision_or_span, sge.Var):
return dt.Interval(unit=precision_or_span.this, nullable=nullable)
elif precision_or_span is None:
raise com.IbisTypeError("Interval precision is None")
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
t0.title,
t0.tags
FROM `bigquery-public-data`.stackoverflow.posts_questions AS t0
`t0`.`title`,
`t0`.`tags`
FROM `bigquery-public-data`.`stackoverflow`.`posts_questions` AS `t0`
WHERE
strpos(t0.tags, 'ibis') > 0
strpos(`t0`.`tags`, 'ibis') > 0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SELECT
t2.title
FROM `bigquery-public-data`.stackoverflow.posts_questions AS t2
INNER JOIN `nyc-tlc`.yellow.trips AS t3
ON t2.tags = t3.rate_code
`t2`.`title`
FROM `bigquery-public-data`.`stackoverflow`.`posts_questions` AS `t2`
INNER JOIN `nyc-tlc`.`yellow`.`trips` AS `t3`
ON `t2`.`tags` = `t3`.`rate_code`
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
SELECT
COUNT(t2.foo) AS count
COUNT(`t2`.`foo`) AS `count`
FROM (
SELECT
t1.string_col,
SUM(t1.float_col) AS foo
`t1`.`string_col`,
SUM(`t1`.`float_col`) AS `foo`
FROM (
SELECT
t0.float_col,
t0.timestamp_col,
t0.int_col,
t0.string_col
FROM `ibis-gbq`.ibis_gbq_testing.functional_alltypes AS t0
`t0`.`float_col`,
`t0`.`timestamp_col`,
`t0`.`int_col`,
`t0`.`string_col`
FROM `ibis-gbq`.`ibis_gbq_testing`.`functional_alltypes` AS `t0`
WHERE
t0.timestamp_col < datetime('2014-01-01T00:00:00')
) AS t1
`t0`.`timestamp_col` < datetime('2014-01-01T00:00:00')
) AS `t1`
GROUP BY
1
) AS t2
) AS `t2`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
approx_quantiles(IF(t0.month > 0, t0.double_col, NULL), IF(t0.month > 0, 2, NULL))[offset(1)] AS `ApproxMedian_double_col_ Greater_month_ 0`
FROM functional_alltypes AS t0
approx_quantiles(IF(`t0`.`month` > 0, `t0`.`double_col`, NULL), IF(`t0`.`month` > 0, 2, NULL))[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,3 +1,3 @@
SELECT
APPROX_COUNT_DISTINCT(IF(t0.month > 0, t0.double_col, NULL)) AS `ApproxCountDistinct_double_col_ Greater_month_ 0`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
approx_quantiles(t0.double_col, 2)[offset(1)] AS ApproxMedian_double_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
APPROX_COUNT_DISTINCT(t0.double_col) AS ApproxCountDistinct_double_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
CAST(t0.value AS BYTES) AS `Cast_value_ binary`
FROM t AS t0
CAST(`t0`.`value` AS BYTES) AS `Cast_value_ binary`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +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 AS t0
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,3 +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 AS t0
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,3 +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 AS t0
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,3 +1,3 @@
SELECT
bit_and(t0.int_col) AS BitAnd_int_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
bit_or(t0.int_col) AS BitOr_int_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
bit_xor(t0.int_col) AS BitXor_int_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
AVG(CAST(t0.bool_col AS INT64)) AS Mean_bool_col
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
SUM(CAST(t0.bool_col AS INT64)) AS Sum_bool_col
FROM functional_alltypes AS t0
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,7 +1,13 @@
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
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,3 +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 AS t0
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,17 +1,17 @@
SELECT
CASE
WHEN (
0 <= t0.value
0 <= `t0`.`value`
) AND (
t0.value < 1
`t0`.`value` < 1
)
THEN 0
WHEN (
1 <= t0.value
1 <= `t0`.`value`
) AND (
t0.value <= 3
`t0`.`value` <= 3
)
THEN 1
ELSE CAST(NULL AS INT64)
END AS tmp
FROM t AS t0
END AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
CAST(trunc(t0.double_col) AS INT64) AS `Cast_double_col_ int64`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
SUM(t0.foo) AS Sum_foo
FROM t0 AS t0
SUM(`t0`.`foo`) AS `Sum_foo`
FROM `t0` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
COVAR_POP(t0.double_col, t0.double_col) AS `Covariance_double_col_ double_col`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
COVAR_SAMP(t0.double_col, t0.double_col) AS `Covariance_double_col_ double_col`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
CAST(FLOOR(ieee_divide(t0.double_col, 0)) AS INT64) AS `FloorDivide_double_col_ 0`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
ieee_divide(t0.double_col, 0) AS `Divide_double_col_ 0`
FROM functional_alltypes AS t0
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,3 +1,3 @@
SELECT
DATE(t0.ts) AS tmp
FROM t AS t0
DATE(`t0`.`ts`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
time(t0.ts) AS tmp
FROM t AS t0
time(`t0`.`ts`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_azimuth(t0.p0, t0.p1) AS tmp
FROM t AS t0
st_azimuth(`t0`.`p0`, `t0`.`p1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_contains(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_contains(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_coveredby(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_coveredby(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_covers(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_covers(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_dwithin(t0.geog0, t0.geog1, 5.2) AS tmp
FROM t AS t0
st_dwithin(`t0`.`geog0`, `t0`.`geog1`, 5.2) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_difference(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_difference(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_disjoint(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_disjoint(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_distance(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_distance(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
st_equals(t0.geog0, t0.geog1) AS tmp
FROM t AS t0
st_equals(`t0`.`geog0`, `t0`.`geog1`) AS `tmp`
FROM `t` AS `t0`
Loading

0 comments on commit e68000c

Please sign in to comment.