public class TestCsvWithSchema extends BaseCsvTest
DrillTest.MemWatcher| Modifier and Type | Field and Description |
|---|---|
protected static String |
FILE1_NAME |
BIG_COL_SIZE, EMPTY_FILE, FILE_N_NAME, NESTED_DIR, NESTED_FILE, PART_DIR, ROOT_FILE, SCHEMA_BATCH_ENABLED, secondFile, testDir, validHeadersclient, cluster, dirTestWatcherlogOutcome, objectMapper, REPEAT_RULE, thrownException, TIMEOUT| Constructor and Description |
|---|
TestCsvWithSchema() |
| Modifier and Type | Method and Description |
|---|---|
static void |
setup() |
void |
testBasicSchema()
Test the simplest possible case: a table with one file:
Column in projection, table, and schema
Column in projection and table but not in schema.
Column in projection and schema, but not in table.
Column in projection, but not in schema or table.
|
void |
testBlankCols()
Demonstrate that CSV uses a comma to introduce a column,
even if that column has no data.
|
void |
testBlankColsWithNoDefaultValue()
As above, but with a non-nullable numeric column with a default
value.
|
void |
testBlankColsWithNullableSchema()
As above, but with a nullable numeric column.
|
void |
testBlankColsWithSchema()
Use the same data set as above tests, but use a schema to do type
conversion.
|
void |
testBool()
Test the many ways to specify True for boolean columns.
|
void |
testDateColDefault()
Use a user-provided default value for a missing required column.
|
void |
testDecimal()
Basic decimal sanity test showing rounding, using default values,
and so on.
|
void |
testDecimalDefaultOverflow()
Test proper handling of overflow for a default value.
|
void |
testDecimalDefaultRound()
Verify that the decimal default value is rounded according
to the scale specified in the decimal type.
|
void |
testDecimalNoPrecOrScale()
Verify that a decimal type without precision or scale defaults
to precision of 38, scale of 0.
|
void |
testDecimalNoScale()
Verify that a decimal type with no scale defaults to a scale of 0.
|
void |
testDecimalOverflow()
Test decimal overflow during data reads.
|
void |
testExplicitSort()
Because V3 uses VARCHAR for missing columns, and handles ragged rows, there
is no vector corruption, and the sort operator sees a uniform schema, even
without a schema.
|
void |
testInvalidDecimalSchema() |
void |
testMissingCols() |
void |
testMissingColsNullable()
Demonstrate that CSV works for a schema with nullable types when columns
are missing (there is no comma to introduce an empty field in the data.)
|
void |
testMissingColsReq()
Verify that, if a schema is provided, a column is missing,
and there is no default, that the mode is left at required and
the column is filled with zeros.
|
void |
testMissingColsReqDefault()
Verify the behavior of missing columns, not null mode, with
a default value.
|
void |
testMissingRequiredCol()
Show that the projection framework generates a reasonable default value
if told to create a required column that does not exist.
|
void |
testMultiFileSchema()
Use a schema with explicit projection to get a consistent view
of the table schema, even if columns are missing, rows are ragged,
and column order changes.
|
void |
testMultiFileSchemaMissingCol()
Test the case that a file does not contain a required column (in this case,
id in the third file.) There are two choices.
|
void |
testMultiFragmentStrictSchema()
Test a strict schema where it is needed most: in a scan with multiple
fragments, each of which sees a different reader schema.
|
void |
testRequiredColDefault()
Use a user-provided default value for a missing required column.
|
void |
testSchemaExplicitSort()
Adding a schema makes the data types more uniform, and fills in defaults
for missing columns.
|
void |
testWildcardLenientSchema()
Test lenient wildcard projection.
|
void |
testWildcardSortFailure()
Show that, without schema, the hard schema change for the "missing"
gender column causes an error in the sort operator when presented with
one batch in which gender is VARCHAR, another in which it is
Nullable INT.
|
void |
testWildcardStrictSchema()
Test wildcard projection with a strict schema: only schema columns are
projected.
|
buildBigColFile, buildFile, buildFile, buildNestedTable, buildTable, enableMultiScan, enableSchema, enableSchemaSupport, resetMultiScan, resetSchema, resetSchemaSupport, setup, setupgetFile, queryBuilder, run, runAndLog, runAndPrint, runAndPrint, shutdown, startCluster, testBuilderescapeJsonString, finishDrillTest, initDrillTestprotected static final String FILE1_NAME
public void testBasicSchema()
throws Exception
Exceptionpublic void testMissingRequiredCol()
throws Exception
Exceptionpublic void testRequiredColDefault()
throws Exception
Exceptionpublic void testDateColDefault()
throws Exception
Exceptionpublic void testMultiFileSchema()
throws Exception
Force the scans to occur in distinct fragments so the order of the file batches is random.
Exceptionpublic void testWildcardSortFailure()
throws Exception
Exceptionpublic void testExplicitSort()
throws Exception
This and other tests enable multiple scan fragments, even for small files, then run the test multiple times to generate the result set in different orders (file1 first sometimes, file2 other times.)
Exceptionpublic void testSchemaExplicitSort()
throws Exception
Exceptionpublic void testMultiFileSchemaMissingCol()
throws Exception
Inserts an ORDER BY to force a single batch in a known order. Assumes the other ORDER BY tests pass.
This test shows that having consistent types is sufficient for the sort operator to work; the DAG will include a project operator that reorders the columns when produced by readers in different orders. (Column ordering is more an abstract concept anyway in a columnar system such as Drill.)
Exceptionpublic void testWildcardLenientSchema()
throws Exception
Exceptionpublic void testWildcardStrictSchema()
throws Exception
Exceptionpublic void testMultiFragmentStrictSchema()
throws Exception
Exceptionpublic void testBool()
throws Exception
Exceptionpublic void testDecimal()
throws Exception
Exceptionpublic void testDecimalNoPrecOrScale()
throws Exception
Exceptionpublic void testDecimalNoScale()
throws Exception
Exceptionpublic void testDecimalDefaultRound()
throws Exception
Exceptionpublic void testDecimalOverflow()
throws Exception
Exceptionpublic void testDecimalDefaultOverflow()
throws Exception
Exceptionpublic void testMissingColsReq()
throws Exception
Exceptionpublic void testMissingColsReqDefault()
throws Exception
Exceptionpublic void testMissingColsNullable()
throws Exception
Exceptionpublic void testBlankCols()
throws Exception
Such a schema cannot be converted to a number or date column, even nullable, because a blank string is neither a valid number nor a valid date.
Exceptionpublic void testBlankColsWithSchema()
throws Exception
Exceptionpublic void testBlankColsWithNullableSchema()
throws Exception
ExceptionCopyright © 2021 The Apache Software Foundation. All rights reserved.