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

Function build_partitioned_load

testdata/bin/generate-schema-statements.py:551–580  ·  view source on GitHub ↗
(insert, re_match, can_hint, params)

Source from the content-addressed store, hash-verified

549
550
551def build_partitioned_load(insert, re_match, can_hint, params):
552 part_col = re_match.group(1)
553 min_val = int(re_match.group(2))
554 max_val = int(re_match.group(3))
555 batch = int(re_match.group(4))
556 insert = PARTITIONED_INSERT_RE.sub("", insert)
557 statements = []
558 params[VAR_HINT] = HINT_SHUFFLE if can_hint else ''
559 first_part = min_val
560 while first_part < max_val:
561 if first_part + batch >= max_val:
562 # This is the last batch
563 if first_part == min_val:
564 # There is only 1 batch in this insert. No predicate needed.
565 params[VAR_PART_PREDICATE] = ''
566 else:
567 # Insert the remaining partitions + NULL partition
568 params[VAR_PART_PREDICATE] = "WHERE {0} <= {1} OR {2} IS NULL".format(
569 first_part, part_col, part_col)
570 elif first_part == min_val:
571 # This is the first batch.
572 params[VAR_PART_PREDICATE] = "WHERE {0} < {1}".format(
573 part_col, first_part + batch)
574 else:
575 # This is the middle batch.
576 params[VAR_PART_PREDICATE] = "WHERE {0} <= {1} AND {2} < {3}".format(
577 first_part, part_col, part_col, first_part + batch)
578 statements.append(insert.format(**params))
579 first_part += batch
580 return "\n".join(statements)
581
582
583def build_insert_into_statement(insert, db_name, db_suffix, table_name, file_format,

Callers 2

build_load_statementFunction · 0.85

Calls 3

formatMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected