Skip to content
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

refactor(ir): rethink the relational operations #7580

Closed
wants to merge 449 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
449 commits
Select commit Hold shift + click to select a range
8c2bb77
chore(clickhouse): remove duplicate impls
cpcloud Nov 29, 2023
a0f7bb1
chore: even more consolidation
cpcloud Nov 29, 2023
7ca0bdf
chore: even more consolidation of clickhouse
cpcloud Nov 29, 2023
ebdfbe1
chore: remove non-explicit kwargs
cpcloud Nov 29, 2023
3f66a2f
chore: comment about todo for arrayconcat
cpcloud Nov 29, 2023
73f2ae6
chore(duckdb): clean up intervalfrominteger impl
cpcloud Nov 29, 2023
f5915f2
chore: base count distinct star operation; better error message on ar…
cpcloud Nov 29, 2023
cf1ffe5
chore(snowflake): remove snowflake-sqlalchemy dep
cpcloud Nov 29, 2023
510d7bb
chore: move sqlglot compiler out of unnecessary package
cpcloud Nov 29, 2023
e0a4a3f
chore: consolidate backends; clickhouse passing
cpcloud Nov 29, 2023
7aca543
chore: consolidate backends; sqlglot backends all passing
cpcloud Nov 29, 2023
bcfff4f
chore: checkpoint
cpcloud Nov 29, 2023
258b489
chore: checkpoint
cpcloud Nov 29, 2023
36af9d4
chore: more snowflake fixes
cpcloud Nov 30, 2023
6dd9fa0
chore: get most tpch working
cpcloud Nov 30, 2023
9276844
chore: fix broken timestamps by removing the sqlalchemy layer
cpcloud Nov 30, 2023
4c8b98f
chore: fix listagg
cpcloud Nov 30, 2023
85a40e9
chore: fix method typo
cpcloud Nov 30, 2023
3cf5f1b
chore: fix quantile
cpcloud Nov 30, 2023
a2f96c9
chore: fix approx median
cpcloud Nov 30, 2023
690505b
chore: fix snowflake counting
cpcloud Nov 30, 2023
c94c6e6
chore: checkpoint
cpcloud Nov 30, 2023
ced2907
chore: fix snowflake first/last in windows by using rewrites
cpcloud Nov 30, 2023
039a062
chore: fix snowflake window order_by requirement
cpcloud Nov 30, 2023
03159dc
chore: fix snowflake binary literals
cpcloud Nov 30, 2023
646fed1
chore: xfail intervalfrominteger
cpcloud Nov 30, 2023
8e05073
chore: xfail some things
cpcloud Nov 30, 2023
79d7c85
chore: fix use of plus
cpcloud Nov 30, 2023
ccff00e
chore(snowflake): fix tests
cpcloud Nov 30, 2023
f1978bb
chore(snowflake): fix nested type transformation
cpcloud Nov 30, 2023
8b81c2a
chore(snowflake): fix limit and xor
cpcloud Nov 30, 2023
742e8f6
chore(snowflake): disable try cast
cpcloud Nov 30, 2023
48098d6
chore(snowflake): handle casting unnest results to their desired outp…
cpcloud Nov 30, 2023
efb15a3
chore(snowflake): fix unnest
cpcloud Dec 1, 2023
ee52b70
chore(snowflake): bring back xfails
cpcloud Dec 1, 2023
7a6dce9
chore(snowflake): pass dialect to delta
cpcloud Dec 1, 2023
7a07c64
chore(snowflake): handle the overriding of the RowNumber rewrite
cpcloud Dec 1, 2023
12c43f0
chore(snowflake): escape backslashes in string literals
cpcloud Dec 1, 2023
839832a
chore(snowflake): add simple translate impl
cpcloud Dec 1, 2023
05d63df
chore(snowflake): xfail to_delta now because snowflake has more preci…
cpcloud Dec 1, 2023
370133c
chore(snowflake): fix decimal conversion
cpcloud Dec 1, 2023
7155d04
chore(snowflake): fix check
cpcloud Dec 1, 2023
0987397
chore(snowflake): fix epoch
cpcloud Dec 1, 2023
500d390
chore(snowflake): raise on timestampadd
cpcloud Dec 1, 2023
8f652b6
chore(snowflake): implement strftime
cpcloud Dec 1, 2023
bfa3916
chore(snowflake): fix temporal ops
cpcloud Dec 1, 2023
3bd9f98
chore(snowflake): raise on expr window bounds
cpcloud Dec 1, 2023
be5a4b1
chore(sqlglot): constant fold the nth_value offset if possible
cpcloud Dec 1, 2023
0077cdf
chore(sqlglot): fix temp view creation return type
cpcloud Dec 2, 2023
503ddbe
chore(duckdb): fail on decimal nan and inf
cpcloud Dec 2, 2023
4da1301
chore(sqlglot): slots
cpcloud Dec 2, 2023
54a005c
chore(snowflake): make backend more concise
cpcloud Dec 2, 2023
183d202
chore(sqlglot): use sge instead of sg.exp
cpcloud Dec 2, 2023
f6dacc1
chore(datafusion): quoting
cpcloud Dec 2, 2023
f3d62ff
chore(sqlglot): shorten map call
cpcloud Dec 2, 2023
7e76628
chore(sqlglot): make `_metadata` an abstract method
cpcloud Dec 2, 2023
9396af9
chore(tpch-tests): cast expected result to result schema
cpcloud Dec 2, 2023
c51eddc
chore: clean up
cpcloud Dec 2, 2023
262955c
chore: consolidate drop_table and drop_view for sqlglot backends
cpcloud Dec 2, 2023
3ff8686
chore(datafusion): dot sql
cpcloud Dec 2, 2023
ee67409
chore(clickhouse): conform backend to base impl
cpcloud Dec 2, 2023
1966d16
chore(datafusion): enable xpassing tests
cpcloud Dec 2, 2023
4011d9c
chore(datafusion): fix xpassing
cpcloud Dec 2, 2023
f642bc6
chore(snowflake): sort simple ops
cpcloud Dec 2, 2023
945e474
chore(sqlglot): clean up array size and sort
cpcloud Dec 2, 2023
4b0f74d
chore(sqlglot): clean up more common rules
cpcloud Dec 2, 2023
f85f269
chore(sqlglot): clean up more common rules
cpcloud Dec 2, 2023
7e38c22
chore(sqlglot): clean up more common rules
cpcloud Dec 2, 2023
f992367
chore(sqlglot): clean up more common rules
cpcloud Dec 2, 2023
990d56b
chore(snowflake): consolidate map/struct literal construction
cpcloud Dec 2, 2023
4684efa
chore(snowflake): fix to json rule
cpcloud Dec 2, 2023
f5237d2
chore(snowflake): fix log
cpcloud Dec 2, 2023
823f1d1
chore(snowflake): fix struct literals
cpcloud Dec 2, 2023
04a6329
chore(snowflake): fix timestamp and date addition
cpcloud Dec 2, 2023
09fbab8
chore(snowflake): consolidate date and timestamp addition
cpcloud Dec 2, 2023
6ecc6be
chore(snowflake): fix windows
cpcloud Dec 2, 2023
0368a7b
chore(snowflake): fix tpch
cpcloud Dec 2, 2023
cd47d1f
chore(snowflake-tpch): push limits into subqueries
cpcloud Dec 2, 2023
6ac2d1a
chore(formats): simplify decimal to pandas impl
cpcloud Dec 2, 2023
4c7382c
chore: bring back annoying decimal to pandas impl to help truncate
cpcloud Dec 2, 2023
26a1611
chore(snowflake): fix udf tests
cpcloud Dec 2, 2023
66d9bbd
chore: do not merge chained limits
cpcloud Dec 2, 2023
11a488a
chore(snowflake): fix udfs
cpcloud Dec 2, 2023
18c08f6
chore(snowflake): fix udfs
cpcloud Dec 2, 2023
ef21022
chore(snowflake): remove dead code
cpcloud Dec 2, 2023
8e4ce05
chore(duckdb): decimal literal type errors
cpcloud Dec 2, 2023
1caff76
chore: use timetostr
cpcloud Dec 2, 2023
a3c43f8
chore: move _neg_idx_to_pos
cpcloud Dec 2, 2023
ec8480a
chore(duckdb): clean up create table
cpcloud Dec 3, 2023
89768e0
chore(duckdb): clean up create table
cpcloud Dec 3, 2023
c6f40d8
chore(duckdb): clean up load extensions
cpcloud Dec 3, 2023
60455e1
chore: checkpoint
cpcloud Dec 4, 2023
3351ef7
chore: checkpoint
cpcloud Dec 4, 2023
2a90eec
chore: checkpoint
cpcloud Dec 4, 2023
ecd8228
chore: remove breakpoint and add comment
cpcloud Dec 5, 2023
45974d0
chore(bigquery): clean up some docs
cpcloud Dec 5, 2023
8f39b75
chore: always not null since make_session was called
cpcloud Dec 5, 2023
6f5d004
style: formatting
cpcloud Dec 5, 2023
3f2f2bd
chore: fix array construction
cpcloud Dec 5, 2023
416241d
chore: show dtype in failing assertion
cpcloud Dec 5, 2023
7041dcf
chore: avoid some noisy sql by using ordinal
cpcloud Dec 5, 2023
cdfd3f6
chore: reenable snowflake data loading
cpcloud Dec 5, 2023
ea7f40c
chore: fix safe_ordinal call
cpcloud Dec 5, 2023
1d280b4
chore: add geospatial duckdb to new compiler
cpcloud Dec 5, 2023
0237d87
refactor(pandas): first batch of changes to rewrite the pandas backen…
kszucs Nov 28, 2023
8013d83
refactor(pandas): second batch of changes
kszucs Nov 28, 2023
0040af0
refactor(pandas): suppoer isin subqueries
kszucs Nov 28, 2023
0ac84ff
refactor(pandas): trying to make aggregations work
kszucs Nov 29, 2023
21be012
e
kszucs Nov 29, 2023
9702369
f
kszucs Nov 29, 2023
ea740ec
better rewrite
kszucs Nov 29, 2023
4122afd
groupby aggs working
kszucs Nov 30, 2023
6ebfab6
implement more reductions
kszucs Nov 30, 2023
f2cfc2e
chore(pandas): array functions and params
kszucs Nov 30, 2023
0f007b1
chore(pandas): introduce rowwise and elementwise helpers
kszucs Nov 30, 2023
16e081b
chore(pandas): more string operations and other fixes
kszucs Nov 30, 2023
d76783a
chore(pandas): numeric ops
kszucs Nov 30, 2023
d508009
chore(pandas): add temporal operations
kszucs Dec 1, 2023
bd3a4da
chore(pandas): implementation picking heuristics
kszucs Dec 1, 2023
23faf60
chore(pandas): fix table reduction; convert everything to table shape…
kszucs Dec 1, 2023
9a606a2
chore(pandas): implement setops, covariance and correlation reductions
kszucs Dec 1, 2023
53d25c9
chore(pandas): fix combine step in PandasReduce
kszucs Dec 1, 2023
1192211
chore(pandas): implement additional reductions; fix a couple ir IR an…
kszucs Dec 1, 2023
541cbba
chore(pandas): implement map functions
kszucs Dec 1, 2023
d61a45c
chore(pandas): fix array flattan
kszucs Dec 1, 2023
875ace1
chore(pandas): initial support for joins
kszucs Dec 1, 2023
1037b71
chore(pandas): fix field references for nested joins
kszucs Dec 2, 2023
317bd8a
chore(pandas): support 'primitive' join predicates
kszucs Dec 2, 2023
a4a848c
chore(pandas): add struct functions
kszucs Dec 2, 2023
c8de527
chore(pandas): add support for SearchedCase
kszucs Dec 2, 2023
6638972
chore(pandas): various fix for casting series and scalar objects
kszucs Dec 2, 2023
a7e1ca6
chore(pandas): better NA handling
kszucs Dec 2, 2023
3b19856
chore(pandas): ass JSONGetItem and FindInSet
kszucs Dec 2, 2023
e58c657
chore(pandas): update severeral temporal function implementations; CH…
kszucs Dec 2, 2023
670ed87
chore(pandas): added a cuple of temporal functions; CHANGED THE panda…
kszucs Dec 2, 2023
4305690
chore(pandas): fix various join tests which were incorrect
kszucs Dec 2, 2023
efc2d29
chore(pandas): add ops.Repeat columnwise implementation
kszucs Dec 2, 2023
5cdd0cd
chore(pandas): map and array test case fixes
kszucs Dec 2, 2023
5696322
chore(pandas): implement asof, semi and anti joins
kszucs Dec 3, 2023
b155576
chore(pandas): implement support for udfs
kszucs Dec 3, 2023
3de335e
chore(pandas): add support for array unnest
kszucs Dec 3, 2023
6694493
chore(pandas): fix multi quantile
kszucs Dec 3, 2023
d98ad38
refactor(common): clean up the finder and replacer function construct…
kszucs Dec 3, 2023
c58af9e
chore(pandas): rewrite rule for window functions and first implementa…
kszucs Dec 4, 2023
a216ed5
chore(pandas): add decimal support for a couple of numerical methods;…
kszucs Dec 5, 2023
c6e556f
refactor(pandas): remove code related to the old implementation; reor…
kszucs Dec 5, 2023
2c0e47f
chore(pandas): fix misc testing issues
kszucs Dec 5, 2023
f54a7fd
chore(pandas): implement ops.Difference and ops.SelfReference
kszucs Dec 5, 2023
c376245
chore: regen geo sql
cpcloud Dec 5, 2023
df5308a
chore: fix geo rebase updates
cpcloud Dec 5, 2023
8df561a
chore: fix geo rebase updates
cpcloud Dec 5, 2023
d8fcce6
chore: fix geo union
cpcloud Dec 5, 2023
2d99fd6
chore: clean up duckdb snapshots after limit squashing
cpcloud Dec 5, 2023
0ec8e1c
chore(duckdb): fix _to_sqlglot return type
cpcloud Dec 5, 2023
09aff79
chore(duckdb): fix read_csv columns
cpcloud Dec 5, 2023
18ea942
chore(pandas-conversion): bring back decimals
cpcloud Dec 5, 2023
d515992
chore(pandas-conversion): maps are lists of pairs now; fix code assum…
cpcloud Dec 5, 2023
9d02e67
chore: handle list of pairs with mappings
cpcloud Dec 5, 2023
b8bd2d5
chore: handle json as objects
cpcloud Dec 5, 2023
ef823e6
fix(formats): fix none handling for struct and json types
kszucs Dec 5, 2023
f3d7fad
chore: enable duckdb -> snowflake test
cpcloud Dec 5, 2023
6515309
chore: fix clickhouse
cpcloud Dec 5, 2023
c704edc
chore(clickhouse): fix inet
cpcloud Dec 5, 2023
9ea580a
chore(clickhouse): fix struct from tuple
cpcloud Dec 5, 2023
ee6bf70
fix(formats): restore pandas timestamp conversion logic
kszucs Dec 5, 2023
fd91318
chore(clickhouse): undefined stringtotimestamp
cpcloud Dec 5, 2023
bba6636
chore(duckdb): inet tests
cpcloud Dec 5, 2023
2182de7
chore(datafusion): fix compiler and disable stringtotimestamp
cpcloud Dec 5, 2023
ac0282c
chore(formats): revert all changes made to the formats
kszucs Dec 5, 2023
e6beb10
Revert "chore(duckdb): inet tests"
kszucs Dec 5, 2023
daa4372
chore(duckdb): update the decimal nan/inf tests
kszucs Dec 5, 2023
98d6d21
chore: remove ast builder tests
cpcloud Dec 5, 2023
39d4b2f
chore: move sql tests to backend
cpcloud Dec 5, 2023
8f17ead
chore(pandas): remove additional code from old implementation
kszucs Dec 5, 2023
34adda9
chore: update sql tests
cpcloud Dec 6, 2023
96c0aff
chore: clean up snowflake `_to_sqlglot` call
cpcloud Dec 6, 2023
6745c20
chore(deps): ignore broken sqlglot version
cpcloud Dec 6, 2023
863ed6b
chore(snowflake): remove unnecessary cursor in test setup
cpcloud Dec 6, 2023
7c381f2
chore(snowflake): move base correlation impl to subclass
cpcloud Dec 6, 2023
3d0846c
chore(snowflake): remove unused import of `STAR`
cpcloud Dec 6, 2023
19d30cc
chore(snowflake): make `array_contains` generic
cpcloud Dec 6, 2023
8a671f0
chore(snowflake): move base correlation impl to subclass
cpcloud Dec 6, 2023
43c103f
chore(snowflake): single struct field xpass
cpcloud Dec 6, 2023
98bf7bf
chore(snowflake): fix empty array
cpcloud Dec 6, 2023
9b71ad0
chore(snowflake): fix range single argument unnest xpass
cpcloud Dec 6, 2023
a332ed6
chore(pandas-data): decimal conversion
cpcloud Dec 6, 2023
ae40fee
test(clickhouse): add test for #6838.
cpcloud Dec 6, 2023
bc92235
test(joins): add test for #7288.
cpcloud Dec 6, 2023
ce9879f
test(pandas): add test for #4309.
cpcloud Dec 6, 2023
d84d063
test(sql): add failing test for #5655.
cpcloud Dec 6, 2023
0d55274
chore: remove bogus optimize call
cpcloud Dec 7, 2023
c221823
chore: remove optimize call
cpcloud Dec 7, 2023
a684bfc
feat(sql): add rewrites to construct a SQL-friendly Select node
kszucs Dec 7, 2023
3e5b859
fix(sql): fix the standalone Filter and Sort rewrites for sqlize()
kszucs Dec 7, 2023
38fa081
chore: generate bogus sql
cpcloud Dec 7, 2023
36df9d9
chore: compile Select
cpcloud Dec 7, 2023
842ed47
fix(sql): add join property to select
kszucs Dec 7, 2023
fea0bbc
chore(polars): add failing test for #7345.
cpcloud Dec 7, 2023
88c51ec
fix(sql): fix for #5655
cpcloud Dec 7, 2023
eca7dde
chore: keys not sort_keys
cpcloud Dec 7, 2023
c4b1345
chore: avoid table name variance in tests
cpcloud Dec 7, 2023
d4b3bb6
chore: correct sqlization
cpcloud Dec 7, 2023
99e1964
chore: add select rewrite ignoring window functions
cpcloud Dec 7, 2023
53a9006
chore(pandas): add tests for window boundary adjustments
kszucs Dec 7, 2023
fbeb1b5
chore(pandas): fix lead and lag implementation
kszucs Dec 7, 2023
09f6783
chore: rewrite with parent
cpcloud Dec 7, 2023
8872d98
test: add test for #7350
cpcloud Dec 7, 2023
b72b096
refactor(ir): only allow field references in JoinChain.fields attribu…
kszucs Dec 8, 2023
3d6d19f
fix(sql): don't merge Select objects if the parent has window functions
kszucs Dec 8, 2023
9494f87
chore: commit valid test_many_subqueries fix
cpcloud Dec 8, 2023
e4ef29f
refactor(sql): remove the joins attribute of SQL Select node
kszucs Dec 8, 2023
e846a50
fix(sql): don't merge Select objects if the outer select has window f…
kszucs Dec 8, 2023
c7e4461
chore: commit valid snapshot updates
cpcloud Dec 8, 2023
44a7e5e
fix(ir): insert SelfReference to the join's right hand side if the tw…
kszucs Dec 8, 2023
a23235b
refactor(ir): all join participants are now boxed relations
kszucs Dec 8, 2023
d980379
Revert "refactor(ir): all join participants are now boxed relations"
kszucs Dec 11, 2023
fe61fa8
chore(pandas): committing missing convert.py
kszucs Dec 11, 2023
3355f35
refactor(ir): wrap join link tables in a SelfReference
kszucs Dec 11, 2023
13b0f5b
chore(ir): remove the only-field restriction from join chain fields w…
kszucs Dec 11, 2023
5f22fc5
chore(ir): do the predicate binding and dereferencing at the same place
kszucs Dec 12, 2023
70821fb
test(ir): update newrels join test cases
kszucs Dec 12, 2023
c5f6fe3
test(ir): update core join tests to conform with the new IR
kszucs Dec 12, 2023
a96cf74
chore(clickhouse): update snapshots
cpcloud Dec 12, 2023
77835a6
chore(duckdb): correlation
cpcloud Dec 12, 2023
d9ced2d
chore(conversion): use `normalize_decimal` instead of casting with py…
cpcloud Dec 12, 2023
4253783
chore(duckdb): regenerate sql
cpcloud Dec 12, 2023
05ff248
chore(duckdb): regenerate tpch sql
cpcloud Dec 12, 2023
6d1369b
chore(formats): make decimal conversion less strict
cpcloud Dec 12, 2023
aa973e8
test(duckdb): enable xpassing tests
cpcloud Dec 12, 2023
94c1108
test(window): remove unused fixture
cpcloud Dec 12, 2023
050ac03
test(sql): add test that verifies no carestian joins
cpcloud Dec 12, 2023
514ad0f
chore(ir): tie the uniqueness of a self reference to its parent
cpcloud Dec 12, 2023
eca7b8f
revert: chore(ir): tie the uniqueness of a self reference to its parent
cpcloud Dec 12, 2023
0a690b0
fix(ir): resolve the mind-bending self-join-dereferencing problem
kszucs Dec 12, 2023
895cbf2
fix(sql): don't merge selections if either the outer or the inner has…
kszucs Dec 12, 2023
78f10a9
test(ir): remove useless format test
kszucs Dec 12, 2023
22cc7be
fix(sql): don't merge selects if the parent projection has array unnest
kszucs Dec 12, 2023
3d69c33
perf(common): improve the performance of replacing nodes by using a s…
kszucs Dec 12, 2023
c318e17
chore(duckdb): regen sql
cpcloud Dec 12, 2023
95374a4
chore: clean up concat
cpcloud Dec 14, 2023
75a0204
chore(duckdb): regen tpch sql
cpcloud Dec 14, 2023
1df588d
chore(deps): relock
cpcloud Dec 14, 2023
bf041fe
chore(snowflake): fix import typo
cpcloud Dec 14, 2023
c1ff686
chore(snowflake): regen tpch sql
cpcloud Dec 14, 2023
ee7f288
chore(snowflake): regen other sql
cpcloud Dec 14, 2023
15e2873
chore(snowflake): replace `_compile_type` use
cpcloud Dec 14, 2023
7ba80b0
chore(snowflake): clean up
cpcloud Dec 14, 2023
3978afd
chore(snowflake): remove `registry.py`
cpcloud Dec 14, 2023
59fdb89
chore(snowflake): fix metadata queries
cpcloud Dec 14, 2023
d9591f7
test(cte-order): add test case for #7776
cpcloud Dec 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"addLabels": ["bigquery"]
},
{
"matchPackagePatterns": ["duckdb", "duckdb-engine"],
"matchPackagePatterns": ["duckdb"],
"addLabels": ["duckdb"]
},
{
Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/extending/sql.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ with closing(con.raw_sql("CREATE TEMP TABLE my_table AS SELECT * FROM RANGE(10)"

Here's an example:

```{python}
```python
cur = con.raw_sql("CREATE TEMP TABLE t AS SELECT * FROM RANGE(10)")
cur.close() # <1>
```
Expand Down
4 changes: 2 additions & 2 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,9 @@ def _cached(self, expr: ir.Table):
if (result := self._query_cache.get(op)) is None:
self._query_cache.store(expr)
result = self._query_cache[op]
return ir.CachedTable(result)
return ir.CachedTableExpr(result)

def _release_cached(self, expr: ir.CachedTable) -> None:
def _release_cached(self, expr: ir.CachedTableExpr) -> None:
"""Releases the provided cached expression.

Parameters
Expand Down
20 changes: 10 additions & 10 deletions ibis/backends/base/df/timecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,19 @@ def adjust_context_alias(
return adjust_context(op.arg, scope, timecontext)


@adjust_context.register(ops.AsOfJoin)
def adjust_context_asof_join(
op: ops.AsOfJoin, scope: Scope, timecontext: TimeContext
) -> TimeContext:
begin, end = timecontext
# @adjust_context.register(ops.AsOfJoin)
# def adjust_context_asof_join(
# op: ops.AsOfJoin, scope: Scope, timecontext: TimeContext
# ) -> TimeContext:
# begin, end = timecontext

if op.tolerance is not None:
from ibis.backends.pandas.execution import execute
# if op.tolerance is not None:
# from ibis.backends.pandas.execution import execute

timedelta = execute(op.tolerance)
return (begin - timedelta, end)
# timedelta = execute(op.tolerance)
# return (begin - timedelta, end)

return timecontext
# return timecontext


@adjust_context.register(ops.WindowFunction)
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/base/sql/alchemy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ class array_filter(FunctionElement):
ops.Coalesce: varargs(sa.func.coalesce),
ops.NullIf: fixed_arity(sa.func.nullif, 2),
ops.InValues: _in_values,
ops.InColumn: _in_column,
ops.InSubquery: _in_column,
ops.Count: reduction(sa.func.count),
ops.CountStar: _count_star,
ops.CountDistinctStar: _count_distinct_star,
Expand All @@ -629,8 +629,7 @@ class array_filter(FunctionElement):
ops.Literal: _literal,
ops.SimpleCase: _simple_case,
ops.SearchedCase: _searched_case,
ops.TableColumn: _table_column,
ops.TableArrayView: _table_array_view,
ops.Field: _table_column,
ops.ExistsSubquery: _exists_subquery,
# miscellaneous varargs
ops.Least: varargs(sa.func.least),
Expand Down
18 changes: 9 additions & 9 deletions ibis/backends/base/sql/compiler/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@


class TableSetFormatter:
_join_names = {
ops.InnerJoin: "INNER JOIN",
ops.LeftJoin: "LEFT OUTER JOIN",
ops.RightJoin: "RIGHT OUTER JOIN",
ops.OuterJoin: "FULL OUTER JOIN",
ops.LeftAntiJoin: "LEFT ANTI JOIN",
ops.LeftSemiJoin: "LEFT SEMI JOIN",
ops.CrossJoin: "CROSS JOIN",
}
# _join_names = {
# ops.InnerJoin: "INNER JOIN",
# ops.LeftJoin: "LEFT OUTER JOIN",
# ops.RightJoin: "RIGHT OUTER JOIN",
# ops.OuterJoin: "FULL OUTER JOIN",
# ops.LeftAntiJoin: "LEFT ANTI JOIN",
# ops.LeftSemiJoin: "LEFT SEMI JOIN",
# ops.CrossJoin: "CROSS JOIN",
# }

def __init__(self, parent, node, indent=2):
# `parent` is a `Select` instance, not a `TableSetFormatter`
Expand Down
29 changes: 10 additions & 19 deletions ibis/backends/base/sql/compiler/select_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def _populate_context(self):
def _make_table_aliases(self, node):
ctx = self.context

if isinstance(node, ops.Join):
if isinstance(node, ops.JoinChain):
for arg in node.args:
if isinstance(arg, ops.TableNode):
if isinstance(arg, ops.Relation):
self._make_table_aliases(arg)
elif not ctx.is_extracted(node):
ctx.make_alias(node)
Expand All @@ -112,7 +112,7 @@ def _collect_elements(self):

if isinstance(self.op, ops.DummyTable):
self.select_set = list(self.op.values)
elif isinstance(self.op, ops.TableNode):
elif isinstance(self.op, ops.Relation):
self._collect(self.op, toplevel=True)
else:
self.select_set = [self.op]
Expand All @@ -125,7 +125,7 @@ def _collect(self, op, toplevel=False):
f(op, toplevel=toplevel)
elif isinstance(op, (ops.PhysicalTable, ops.SQLQueryResult)):
self._collect_PhysicalTable(op, toplevel=toplevel)
elif isinstance(op, ops.Join):
elif isinstance(op, ops.JoinChain):
self._collect_Join(op, toplevel=toplevel)
elif isinstance(op, ops.WindowingTVF):
self._collect_WindowingTVF(op, toplevel=toplevel)
Expand All @@ -140,7 +140,7 @@ def _collect_Distinct(self, op, toplevel=False):

def _collect_Limit(self, op, toplevel=False):
if toplevel:
if isinstance(table := op.table, ops.Limit):
if isinstance(table := op.parent, ops.Limit):
self.table_set = table
self.select_set = [table]
else:
Expand Down Expand Up @@ -184,27 +184,18 @@ def _collect_Aggregation(self, op, toplevel=False):

self._collect(op.table)

def _collect_Selection(self, op, toplevel=False):
table = op.table
def _collect_Project(self, op, toplevel=False):
table = op.parent

if toplevel:
if isinstance(table, ops.Join):
if isinstance(table, ops.JoinChain):
self._collect_Join(table)
else:
self._collect(table)

selections = op.selections
sort_keys = op.sort_keys
filters = op.predicates

if not selections:
# select *
selections = [table]

self.order_by = sort_keys
self.select_set = selections
selections = op.values
self.select_set = list(selections.values())
self.table_set = table
self.filters = filters

def _collect_InMemoryTable(self, node, toplevel=False):
if toplevel:
Expand Down
5 changes: 2 additions & 3 deletions ibis/backends/base/sql/registry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,10 @@ def count_star(translator, op):
ops.IfElse: fixed_arity("if", 3),
ops.Between: between,
ops.InValues: binary_infix.in_values,
ops.InColumn: binary_infix.in_column,
ops.InSubquery: binary_infix.in_column,
ops.SimpleCase: case.simple_case,
ops.SearchedCase: case.searched_case,
ops.TableColumn: table_column,
ops.TableArrayView: table_array_view,
ops.Field: table_column,
ops.DateAdd: timestamp.timestamp_op("date_add"),
ops.DateSub: timestamp.timestamp_op("date_sub"),
ops.DateDiff: timestamp.timestamp_op("datediff"),
Expand Down
Loading