(self, test_section, test_file_name, test_db_name)
| 171 | class ViewCompatTestCase(object): |
| 172 | |
| 173 | def __init__(self, test_section, test_file_name, test_db_name): |
| 174 | if 'CREATE_VIEW' not in test_section: |
| 175 | assert 0, 'Error in test file %s. Test cases require a '\ |
| 176 | 'CREATE_VIEW section.\n%s' %\ |
| 177 | (test_file_name, pprint.pformat(test_section)) |
| 178 | |
| 179 | self.create_exp_res = None |
| 180 | # get map of expected results from test sections |
| 181 | if 'CREATE_VIEW_RESULTS' in test_section: |
| 182 | self.create_exp_res =\ |
| 183 | self._get_expected_results(test_section['CREATE_VIEW_RESULTS']) |
| 184 | else: |
| 185 | assert 0, 'Error in test file %s. Test cases require a '\ |
| 186 | 'CREATE_VIEW_RESULTS section.\n%s' %\ |
| 187 | (test_file_name, pprint.pformat(test_section)) |
| 188 | |
| 189 | self.query_hive_exp_res = None |
| 190 | if 'QUERY_HIVE_VIEW_RESULTS' in test_section: |
| 191 | self.query_hive_exp_res =\ |
| 192 | self._get_expected_results(test_section['QUERY_HIVE_VIEW_RESULTS']) |
| 193 | |
| 194 | self.query_impala_exp_res = None |
| 195 | if 'QUERY_IMPALA_VIEW_RESULTS' in test_section: |
| 196 | self.query_impala_exp_res =\ |
| 197 | self._get_expected_results(test_section['QUERY_IMPALA_VIEW_RESULTS']) |
| 198 | |
| 199 | if self.query_hive_exp_res is None and self.query_impala_exp_res is None: |
| 200 | assert 0, 'Error in test file %s. Test cases require a QUERY_HIVE_VIEW_RESULTS '\ |
| 201 | 'or QUERY_IMPALA_VIEW_RESULTS section.\n%s' %\ |
| 202 | (test_file_name, pprint.pformat(test_section)) |
| 203 | |
| 204 | # clean test section, remove comments etc. |
| 205 | self.create_view_sql = QueryTestSectionReader.build_query(test_section['CREATE_VIEW']) |
| 206 | |
| 207 | view_name = self._get_view_name(self.create_view_sql) |
| 208 | if view_name.find(".") != -1: |
| 209 | assert 0, 'Error in test file %s. Found unexpected view name %s that is '\ |
| 210 | 'qualified with a database' % (test_file_name, view_name) |
| 211 | |
| 212 | # add db prefix and suffixes to indicate which engine created the view |
| 213 | self.hive_view_name = test_db_name + '.' + view_name + '_hive' |
| 214 | self.impala_view_name = test_db_name + '.' + view_name + '_impala' |
| 215 | |
| 216 | self.hive_create_view_sql =\ |
| 217 | self.create_view_sql.replace(view_name, self.hive_view_name, 1) |
| 218 | self.impala_create_view_sql =\ |
| 219 | self.create_view_sql.replace(view_name, self.impala_view_name, 1) |
| 220 | |
| 221 | # SQL to explain a simple query on the view created by Hive in Hive and Impala |
| 222 | if self.query_hive_exp_res is not None: |
| 223 | self.query_hive_view_sql = 'explain select * from %s' % (self.hive_view_name) |
| 224 | |
| 225 | # SQL to explain a simple query on the view created by Impala in Hive and Impala |
| 226 | if self.query_impala_exp_res is not None: |
| 227 | self.query_impala_view_sql = 'explain select * from %s' % (self.impala_view_name) |
| 228 | |
| 229 | self.drop_hive_view_sql = "drop view %s" % (self.hive_view_name) |
| 230 | self.drop_impala_view_sql = "drop view %s" % (self.impala_view_name) |
nothing calls this directly
no test coverage detected