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

Function parse_test_file

tests/util/test_file_parser.py:149–180  ·  view source on GitHub ↗

Parses an Impala test file Test files have the format: ==== <- Section ---- [Name] <- Named subsection // some text ---- [Name2] <- Named subsection ... ==== The valid section names are passed in to this function. The encoding to use when reading the data can be specified with

(test_file_name, valid_section_names, skip_unknown_sections=True,
    encoding=None)

Source from the content-addressed store, hash-verified

147
148
149def parse_test_file(test_file_name, valid_section_names, skip_unknown_sections=True,
150 encoding=None):
151 """
152 Parses an Impala test file
153
154 Test files have the format:
155 ==== <- Section
156 ---- [Name] <- Named subsection
157 // some text
158 ---- [Name2] <- Named subsection
159 ...
160 ====
161
162 The valid section names are passed in to this function. The encoding to use
163 when reading the data can be specified with the 'encoding' flag.
164 """
165 with open(test_file_name, 'rb') as test_file:
166 file_data = test_file.read()
167 if encoding:
168 file_data = file_data.decode(encoding)
169 else:
170 file_data = file_data.decode('utf-8')
171 if os.environ["USE_APACHE_HIVE_3"] == "true":
172 # Remove Hive 4.0 feature for tpcds_schema_template.sql
173 if "tpcds_schema_template" in test_file_name:
174 # HIVE-20703
175 file_data = file_data.replace(
176 'set hive.optimize.sort.dynamic.partition.threshold=1;', '')
177 # HIVE-18284
178 file_data = file_data.replace('distribute by ss_sold_date_sk', '')
179 return parse_test_file_text(file_data, valid_section_names,
180 skip_unknown_sections)
181
182
183def parse_runtime_profile_table_formats(subsection_comment):

Callers 2

parse_query_test_fileFunction · 0.85

Calls 3

parse_test_file_textFunction · 0.85
decodeMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected