mirror of
https://github.com/apache/impala.git
synced 2026-01-06 15:01:43 -05:00
Impala could crash or return wrong result if it uses codegend avro decoding function to scan avro file that has different schema than table schema. With AVRO-1617 fix, we make sure Impala doesn't use codegen if table schema has less columns than file schema. Change-Id: I268419e421404ad6b084482dee417634f17ecf60 Reviewed-on: http://gerrit.cloudera.org:8080/1696 Reviewed-by: Juan Yu <jyu@cloudera.com> Tested-by: Internal Jenkins
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
# Copyright (c) 2012 Cloudera, Inc. All rights reserved.
|
|
|
|
import pytest
|
|
from subprocess import call
|
|
from subprocess import check_call
|
|
from tests.common.test_vector import *
|
|
from tests.common.impala_test_suite import *
|
|
|
|
# This test requires that testdata/avro_schema_resolution/create_table.sql has been run
|
|
class TestAvroSchemaResolution(ImpalaTestSuite):
|
|
@classmethod
|
|
def get_workload(self):
|
|
return 'functional-query'
|
|
|
|
@classmethod
|
|
def add_test_dimensions(cls):
|
|
super(TestAvroSchemaResolution, cls).add_test_dimensions()
|
|
# avro/snap is the only table format with a schema_resolution_test table
|
|
cls.TestMatrix.add_constraint(lambda v:\
|
|
v.get_value('table_format').file_format == 'avro' and\
|
|
v.get_value('table_format').compression_codec == 'snap')
|
|
|
|
def test_avro_schema_resolution(self, vector):
|
|
self.run_test_case('QueryTest/avro-schema-resolution', vector)
|
|
|
|
def test_avro_c_lib_unicode_nulls(self, vector):
|
|
"""Test for IMPALA-1136 and IMPALA-2161 and unicode characters in the
|
|
schema that were not handled correctly by the Avro C library.
|
|
"""
|
|
result = self.execute_query("select * from functional_avro_snap.avro_unicode_nulls")
|
|
comparison = self.execute_query("select * from functional.liketbl")
|
|
|
|
# If we were not able to properly parse the Avro file schemas, then the result
|
|
# would be empty.
|
|
assert len(comparison.data) == len(result.data)
|
|
for x in range(len(result.data)):
|
|
assert comparison.data[x] == result.data[x]
|
|
|
|
def test_avro_codegen_decoder(self, vector):
|
|
"""Test for IMPALA-2798, verify if Impala returns correct result if table schema
|
|
doesn't match file schema.
|
|
"""
|
|
self.run_test_case('QueryTest/avro-schema-resolution', vector)
|