Comments (2)
Comment by wesm
Monday Jan 05, 2015 at 22:26 GMT
Looked at how sqlalchemy handles this:
http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#self-referential-query-strategies
punchline:
from sqlalchemy.orm import aliased
nodealias = aliased(Node)
SQLsession.query(Node).filter(Node.data=='subchild1').\
join(nodealias, Node.parent).\
filter(nodealias.data=="child2").\
all()
This suggests that having a "view" API (name can change) is a reasonable solution
from ibis.
Comment by wesm
Tuesday Jan 06, 2015 at 17:40 GMT
Closing this. Here's an example of performing an aggregation on a self-joined table:
left = table
right = table.view()
metric = (left['a'] - right['b']).mean().name('metric')
joined = left.inner_join(right, [right['g'] == left['g']])
aggregated = joined.aggregate([metric], by=[left['g']])
The IR for the aggregation (console repr still a little messy, can't tell the parts of the aggregation apart yet) looks like:
ref_0
TableView[table]
a : int8
b : int16
c : int32
d : int64
e : float
f : double
g : string
h : boolean
ref_1
SelfReference[table]
Table: ref_0
Aggregation[table]
InnerJoin[table]
Table: ref_0
Table: ref_1
Equals[array(boolean)]
Column[string] 'g' from table ref_1
Column[string] 'g' from table ref_0
Mean[double]
Subtract[array(int32)]
Column[int8] 'a' from table ref_0
Column[int16] 'b' from table ref_1
Column[string] 'g' from table ref_0
from ibis.
Related Issues (20)
- bug: pandas class SingleBlockManager not defined when declaring pandas scalar udf input type as pd.Series HOT 2
- feat: support pyarrow UDFs for pyspark backend
- bug(geo-duckdb): ibis.read_parquet() binary cast to geometry HOT 2
- bug: timestamp casting from integers in polars is broken HOT 1
- bug: examples broken on mssql backend HOT 6
- bug: typing issue with `filter` method on the table column HOT 2
- bug(mssql): translates null booleans incorrectly HOT 3
- feat: better user experience around ibis examples HOT 4
- perf: Ibis slows down considerably for wider tables HOT 5
- bug(bigquery): different name of column in sql code and table.columns HOT 6
- bug: ibis.trino.connect throwing traceback error HOT 1
- feat(read-apis): give the data source input arguments the same name
- refactor: standardize use of keyword/positional-only arguments
- docs: add a technical blog on sqlglot refactor and technical details for 9.0 HOT 2
- bug: hash() in some backends returns a UINT64, but ops.Hash has dtype int64 HOT 1
- feat: Implement Arrow PyCapsule Interface HOT 4
- test(exasol): a bit of ci flakiness in the new arrow c stream test HOT 1
- feat(duckdb): create tables in external catalogs
- bug: When I alias a dataframe and subsequently use SQL that references its columns, the aliasing process might not allow direct referencing of the original column names.
- bug After a chain join, executing mutate will cause an error. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ibis.