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

Function get_data

testdata/common/widetable.py:86–108  ·  view source on GitHub ↗

Returns the data for the given number of rows and columns as a list of strings, each of which is a row delimited by 'delimiter'.

(num_cols, num_rows, delimiter=',', quote_strings=False)

Source from the content-addressed store, hash-verified

84 return new_iter_fn
85
86def get_data(num_cols, num_rows, delimiter=',', quote_strings=False):
87 """Returns the data for the given number of rows and columns as a list of strings, each
88 of which is a row delimited by 'delimiter'."""
89 generators = [
90 bool_generator, # boolean
91 integer_generator, # tinyint
92 integer_generator, # smallint
93 integer_generator, # int
94 integer_generator, # bigint
95 floating_point_generator, # float
96 floating_point_generator, # double
97 quote(integer_generator) if quote_strings else integer_generator, # string
98 ]
99 # Create a generator instance for each column, cycling through the different types
100 iter = itertools.cycle(generators)
101 column_generators = [next(iter)() for i in range(num_cols)]
102
103 # Populate each row using column_generators
104 rows = []
105 for i in range(num_rows):
106 vals = [next(gen) for gen in column_generators]
107 rows.append(delimiter.join(vals))
108 return rows
109
110if __name__ == "__main__":
111 (options, args) = parser.parse_args()

Callers 1

widetable.pyFile · 0.85

Calls 5

rangeFunction · 0.85
quoteFunction · 0.70
nextFunction · 0.50
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected