Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
srcdir = .
MODULE_big = multicorn
OBJS = src/errors.o src/python.o src/query.o src/multicorn.o
OBJS = src/deparse.o src/errors.o src/python.o src/query.o src/multicorn.o


DATA = $(filter-out $(wildcard sql/*--*.sql),$(wildcard sql/*.sql))
Expand All @@ -19,7 +19,7 @@ directories.stamp:

$(OBJS): directories.stamp

install: python_code
install: python_code

sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql directories.stamp
cp $< $@
Expand Down
37 changes: 35 additions & 2 deletions python/multicorn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,31 @@ def can_sort(self, sortkeys):
"""
return []

def can_pushdown_upperrel(self):
"""
Method called from the planner to ask the FDW whether it supports upper
relation pushdown (i.e. aggregation, grouping, etc.), and if so return
a data structure with appropriate details.

Return:
None if pushdown not supported, otherwise a dictionary containing
more granular details for the planning phase, in the form:

Choose a reason for hiding this comment

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

Needs docs on the expected dict output

Copy link
Author

Choose a reason for hiding this comment

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

Adding docs for it in the next commit.


{
"groupby_supported": <true_or_false>, # can be ommited if false
"agg_functions": {
<PG_agg_func_name>: <foreign_agg_func_name>,
...
},
}

Each entry in `agg_functions` dict corresponds to a maping between
the name of a aggregation function in PostgreSQL, and the equivalent
foreign function. If no mapping exists for an aggregate function any
queries containing it won't be pushed down.
"""
return None

def get_path_keys(self):
u"""
Method called from the planner to add additional Path to the planner.
Expand Down Expand Up @@ -269,7 +294,7 @@ def get_path_keys(self):
"""
return []

def explain(self, quals, columns, sortkeys=None, verbose=False):
def explain(self, quals, columns, sortkeys=None, aggs=None, group_clauses=None, verbose=False):
"""Hook called on explain.

The arguments are the same as the :meth:`execute`, with the addition of
Expand All @@ -280,7 +305,7 @@ def explain(self, quals, columns, sortkeys=None, verbose=False):
"""
return []

def execute(self, quals, columns, sortkeys=None):
def execute(self, quals, columns, sortkeys=None, aggs=None, group_clauses=None):
"""Execute a query in the foreign data wrapper.

This method is called at the first iteration.
Expand Down Expand Up @@ -311,8 +336,16 @@ def execute(self, quals, columns, sortkeys=None):
You should return AT LEAST those columns when returning a
dict. If returning a sequence, every column from the table
should be in the sequence.

Kwargs:
sortkeys (list): A list of :class:`SortKey`
that the FDW said it can enforce.
aggs (dict): A dictionary mapping aggregation key with function and
column to be used in the aggregation operation. Result should be
returned under the provided aggregation key.
group_clauses (list): A list of columns used in GROUP BY statements.
For each column provided the returned response should have a
corresponding value in each row using that column name as the key.

Returns:
An iterable of python objects which can be converted back to PostgreSQL.
Expand Down
Loading