MCPcopy Index your code
hub / github.com/pathwaycom/pathway / _select

Function _select

python/pathway/internals/sql/processing.py:517–606  ·  view source on GitHub ↗
(
    node: sql_expr.Select, context: ContextType
)

Source from the content-addressed store, hash-verified

515
516@register(nodetype=sql_expr.Select)
517def _select(
518 node: sql_expr.Select, context: ContextType
519) -> tuple[table.Table, ContextType]:
520 orig_context = context
521
522 # WITH block
523 context = _with_block(node, context)
524
525 # FROM block
526 tab, context = _from(node.args.pop("from"), context)
527
528 tab, context = _joins_block(node, tab, context)
529
530 # GROUP block
531 if (group_field := node.args.pop("group", None)) is not None:
532 groupby = _group(group_field, context)
533 else:
534 groupby = None
535
536 # args building
537 expr_args = []
538 expr_kwargs = {}
539 for e in node.args.pop("expressions"):
540 ret = _run(e, context)
541 if isinstance(ret, dict):
542 expr_kwargs.update(ret)
543 else:
544 expr_args.append(ret)
545
546 # WHERE block
547 if (where_field := node.args.pop("where", None)) is not None:
548 # mutates `where_field`
549 tab_joined_where, context_subqueries_where = _process_field_for_subqueries(
550 where_field, tab, context, orig_context, ""
551 )
552
553 tab_filter_where = tab_joined_where.select(
554 filter_col=_where(where_field, context_subqueries_where)
555 ).with_universe_of(tab)
556 tab_filtered = tab.filter(tab_filter_where.filter_col)
557 table_replacer = TableSubstitutionDesugaring({tab: tab_filtered})
558 expr_args = [table_replacer.eval_expression(e) for e in expr_args]
559 if groupby is not None:
560 groupby = [table_replacer.eval_expression(e) for e in groupby]
561 expr_kwargs = {
562 name: table_replacer.eval_expression(e) for name, e in expr_kwargs.items()
563 }
564 tab = tab_filtered
565
566 # HAVING block
567 if (having_field := node.args.pop("having", None)) is not None:
568 if groupby is None:
569 groupby = []
570
571 _check_work_done(node)
572
573 # maybe we have implicit GROUP BY
574 if groupby is None:

Callers

nothing calls this directly

Calls 15

_with_blockFunction · 0.85
_fromFunction · 0.85
_joins_blockFunction · 0.85
_groupFunction · 0.85
_whereFunction · 0.85
_check_work_doneFunction · 0.85
ReducerDetectorClass · 0.85
_havingFunction · 0.85
_ReducersGathererClass · 0.85
_HavingHelperClass · 0.85

Tested by

no test coverage detected