Files
impala/testdata/workloads/functional-query/queries/QueryTest/avro-schema-changes.test
Huaisi Xu c6ce32b3b6 IMPALA-3687: Prefer Avro field name during schema reconciliation
Since it is possible to create an Avro table with both column
definitions and an Avro schema, Impala attempts to reconcile
inconsistencies in the two schema definitions, generally preferring the
Avro schema. The only exception to this rule was with
CHAR/VARCHAR/STRING columns, where the column definition was preferred
in order to support tables with CHAR/VARCHAR columns although Avro only
supports STRING. This exception is confusing because the name for such a
column will be taken from the column definition (and not from the Avro
schema).

This patch prefers name, comment from Avro schema definition and
uses column type from column definition for CHAR/VARCHAR/STRING
columns.

Change-Id: Ia3e43b2885853c2b4f207a45a873c9d7f31379cd
Reviewed-on: http://gerrit.cloudera.org:8080/3331
Reviewed-by: Huaisi Xu <hxu@cloudera.com>
Tested-by: Internal Jenkins
2016-07-14 19:04:43 +00:00

70 lines
2.0 KiB
Plaintext

====
---- QUERY
# Create a table with default fileformat and later change it to Avro using
# alter sql. The query runs with stale metadata and a warning should be raised.
# Invalidating metadata should cause the Avro schema to be properly set upon the
# next metadata load.
CREATE EXTERNAL TABLE alltypesagg_staleschema (
id INT,
bool_col BOOLEAN,
tinyint_col INT,
smallint_col INT,
int_col INT,
bigint_col BIGINT,
float_col FLOAT,
double_col DOUBLE,
date_string_col STRING,
string_col STRING,
timestamp_col STRING
)
LOCATION '$FILESYSTEM_PREFIX/test-warehouse/alltypesaggmultifilesnopart_avro_snap'
TBLPROPERTIES ('avro.schema.url'= '$FILESYSTEM_PREFIX/test-warehouse/avro_schemas/functional/alltypesaggmultifilesnopart.json')
====
---- QUERY
alter table alltypesagg_staleschema set fileformat avro
====
---- QUERY
select count(*) from alltypesagg_staleschema
---- CATCH
Missing Avro schema in scan node. This could be due to stale metadata.
====
---- QUERY
invalidate metadata alltypesagg_staleschema
====
---- QUERY
select count(*) from alltypesagg_staleschema
---- RESULTS
11000
---- TYPES
bigint
====
---- QUERY
# IMPALA-3092. Create an Avro table without column definitions and add columns via ALTER
# TABLE. Querying the table should work.
CREATE EXTERNAL TABLE avro_alter_table_add_new_column (
a string,
b string)
STORED AS AVRO
LOCATION '$FILESYSTEM_PREFIX/test-warehouse/tinytable_avro';
ALTER TABLE avro_alter_table_add_new_column ADD COLUMNS (
bool_col boolean,
int_col int,
bigint_col bigint,
float_col float,
double_col double,
timestamp_col timestamp,
decimal_col decimal(2,0),
string_col string)
====
---- QUERY
# Every new column just added should have NULL filled
select * from avro_alter_table_add_new_column
---- RESULTS
'aaaaaaa','bbbbbbb',NULL,NULL,NULL,NULL,NULL,'NULL',NULL,'NULL'
'ccccc','dddd',NULL,NULL,NULL,NULL,NULL,'NULL',NULL,'NULL'
'eeeeeeee','f',NULL,NULL,NULL,NULL,NULL,'NULL',NULL,'NULL'
---- TYPES
string, string, boolean, int, bigint, float, double, string, decimal, string
====