Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
  • Loading branch information
stream2000 committed Jan 18, 2024
1 parent 1ceca3a commit a93b89d
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2334,6 +2334,44 @@ class TestInsertTable extends HoodieSparkSqlTestBase {
})
}

test("Test various data types as partition fields") {
withRecordType()(withTempDir { tmp =>
val tableName = generateTableName

spark.sql(
s"""
|CREATE TABLE $tableName (
| id INT,
| boolean_field BOOLEAN,
| float_field FLOAT,
| byte_field BYTE,
| short_field SHORT,
| decimal_field DECIMAL(10, 5),
| date_field DATE,
| string_field STRING,
| timestamp_field TIMESTAMP
|) USING hudi
| TBLPROPERTIES (primaryKey = 'id')
| PARTITIONED BY (boolean_field, float_field, byte_field, short_field, decimal_field, date_field, string_field, timestamp_field)
|LOCATION '${tmp.getCanonicalPath}'
""".stripMargin)

// Insert data into partitioned table
spark.sql(
s"""
|INSERT INTO $tableName (boolean_field, float_field, byte_field, short_field, decimal_field, date_field, string_field, timestamp_field) VALUES
|(1, TRUE, 1.0, 1, 1, 1234.56789, DATE '2021-01-05', 'partition1', TIMESTAMP '2021-01-05 10:00:00'),
|(2, FALSE, 2.0, 2, 2, 6789.12345, DATE '2021-01-06', 'partition2', TIMESTAMP '2021-01-06 11:00:00')
""".stripMargin)

checkAnswer(s"SELECT id, boolean_field FROM $tableName ORDER BY id")(
Seq(1, true),
Seq(2, false)
)
})
}


def ingestAndValidateDataDupPolicy(tableType: String, tableName: String, tmp: File,
expectedOperationtype: WriteOperationType = WriteOperationType.INSERT,
setOptions: List[String] = List.empty,
Expand Down

0 comments on commit a93b89d

Please sign in to comment.