MCPcopy Create free account
hub / github.com/apache/impala / populate_func_with_vals

Method populate_func_with_vals

tests/comparison/query_generator.py:470–577  ·  view source on GitHub ↗
(self,
      func,
      table_exprs=TableExprList(),
      val_exprs=ValExprList(),
      table_alias_prefix='',
      allow_subquery=False,
      _allow_table_exprs=None)

Source from the content-addressed store, hash-verified

468 return matching_signatures
469
470 def populate_func_with_vals(self,
471 func,
472 table_exprs=TableExprList(),
473 val_exprs=ValExprList(),
474 table_alias_prefix='',
475 allow_subquery=False,
476 _allow_table_exprs=None):
477 if not _allow_table_exprs and func.is_agg:
478 _allow_table_exprs = True
479 elif _allow_table_exprs is None and func.contains_agg:
480 _allow_table_exprs = False
481 elif _allow_table_exprs is None:
482 _allow_table_exprs = True
483 # If a function's return type depends on some of its args then at least one of those
484 # args must not be the NULL literal. Example: IF(false, NULL, NULL) is considered
485 # invalid because the return type cannot be determined.
486 has_non_null_literal_arg = False
487 for idx, arg in enumerate(func.args):
488 signature_arg = func.signature.args[idx]
489 if signature_arg.is_subquery \
490 or (allow_subquery \
491 and self.allow_more_nested_queries \
492 and self.profile.use_scalar_subquery()):
493 usage = self.profile.choose_subquery_predicate_category(
494 func.name(),
495 self.current_query.from_clause.table_exprs.joinable_cols_by_type)
496 if usage is not None \
497 and self.allow_more_nested_queries \
498 and (usage[1] == 'UNCORRELATED'
499 or self.current_query.from_clause.table_exprs.joinable_cols_by_type):
500 use_scalar_subquery = (usage[0] == 'Scalar')
501 use_agg_subquery = (usage[1] == 'AGG')
502 use_correlated_subquery = (usage[2] == 'CORRELATED')
503 if use_correlated_subquery:
504 # TODO: Sometimes this causes an exception because the list is empty
505 join_expr_type = self.profile.choose_type(list(
506 self.current_query.from_clause.table_exprs.joinable_cols_by_type))
507 else:
508 join_expr_type = None
509 select_item_data_types = \
510 [signature_arg.type] if use_scalar_subquery else signature_arg.type
511 query = self.generate_statement(
512 table_exprs,
513 select_item_data_types=select_item_data_types,
514 required_table_expr_col_type=join_expr_type,
515 require_aggregate=use_agg_subquery,
516 # Don't use UNION + LIMIT; IMPALA-1379
517 allow_union_clause=(not signature_arg.is_subquery),
518 table_alias_prefix=(table_alias_prefix +
519 ('t' if use_correlated_subquery else '')),
520 allow_with_clause=self.profile.use_nested_with())
521 if use_scalar_subquery and not use_agg_subquery:
522 # Impala will assume the query will return more than one row unless a LIMIT 1
523 # is added. An ORDER BY will also be added under the assumption that we want
524 # deterministic results.
525 query.order_by_clause = OrderByClause([Int(1)])
526 query.limit_clause = LimitClause(Int(1))
527 if use_correlated_subquery:

Calls 15

generate_statementMethod · 0.95
create_func_treeMethod · 0.95
TableExprListClass · 0.90
ValExprListClass · 0.90
OrderByClauseClass · 0.90
IntClass · 0.90
LimitClauseClass · 0.90
WhereClauseClass · 0.90
SubqueryClass · 0.90
use_scalar_subqueryMethod · 0.80

Tested by

no test coverage detected