Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@

public class NativeQueryRunnerUtils
{
private static final String DEFAULT_STORAGE_FORMAT = "DWRF";

private NativeQueryRunnerUtils() {}

public static Map<String, String> getNativeWorkerHiveProperties()
{
return ImmutableMap.of("hive.parquet.pushdown-filter-enabled", "true",
"hive.orc-compression-codec", "ZSTD", "hive.storage-format", "DWRF");
"hive.orc-compression-codec", "ZSTD", "hive.storage-format", DEFAULT_STORAGE_FORMAT);
}

public static Map<String, String> getNativeWorkerIcebergProperties()
Expand Down Expand Up @@ -78,12 +80,32 @@ public static Map<String, String> getNativeWorkerTpcdsProperties()
*/
public static void createAllTables(QueryRunner queryRunner)
{
createAllTables(queryRunner, "DWRF");
createAllTables(queryRunner, DEFAULT_STORAGE_FORMAT, false);
}

public static void createAllTables(QueryRunner queryRunner, String storageFormat)
{
createLineitem(queryRunner, storageFormat);
createAllTables(queryRunner, storageFormat, false);
}

/**
* Creates all tables for local testing, except for bench tables.
*
* @param queryRunner the QueryRunner instance used to execute table creation queries.
* @param storageFormat File format to use for the tables. If "DWRF" is specified, date columns are cast to
* VARCHAR, since DWRF does not support DATE type.
* @param useTpchStandardSchema when true, lineitem table is created with 16 columns as specified in the TPC-H
* standard; otherwise, the lineitem table is created with additional columns for
* testing purposes.
*/
public static void createAllTables(QueryRunner queryRunner, String storageFormat, boolean useTpchStandardSchema)
{
if (useTpchStandardSchema) {
createLineitemStandard(queryRunner, storageFormat);
}
else {
createLineitem(queryRunner, storageFormat);
}
createOrders(queryRunner, storageFormat);
createOrdersEx(queryRunner);
createOrdersHll(queryRunner);
Expand All @@ -107,7 +129,7 @@ public static void createAllTables(QueryRunner queryRunner, String storageFormat
*/
public static void createAllIcebergTables(QueryRunner queryRunner)
{
createLineitemStandard(queryRunner);
createLineitemStandard(queryRunner, ICEBERG_DEFAULT_STORAGE_FORMAT);
createOrders(queryRunner);
createNationWithFormat(queryRunner, ICEBERG_DEFAULT_STORAGE_FORMAT);
createCustomer(queryRunner);
Expand All @@ -119,7 +141,7 @@ public static void createAllIcebergTables(QueryRunner queryRunner)

public static void createLineitem(QueryRunner queryRunner)
{
createLineitem(queryRunner, "DWRF");
createLineitem(queryRunner, DEFAULT_STORAGE_FORMAT);
}

public static void createLineitem(QueryRunner queryRunner, String storageFormat)
Expand All @@ -142,16 +164,32 @@ public static void createLineitem(QueryRunner queryRunner, String storageFormat)

public static void createLineitemStandard(QueryRunner queryRunner)
{
createLineitemStandard(queryRunner.getDefaultSession(), queryRunner);
createLineitemStandard(queryRunner.getDefaultSession(), queryRunner, DEFAULT_STORAGE_FORMAT);
}

public static void createLineitemStandard(Session session, QueryRunner queryRunner)
{
createLineitemStandard(session, queryRunner, DEFAULT_STORAGE_FORMAT);
}

public static void createLineitemStandard(QueryRunner queryRunner, String storageFormat)
{
createLineitemStandard(queryRunner.getDefaultSession(), queryRunner, storageFormat);
}

public static void createLineitemStandard(Session session, QueryRunner queryRunner, String storageFormat)
{
if (!queryRunner.tableExists(session, "lineitem")) {
boolean castDateToVarchar = storageFormat.equals("DWRF");
String shipDate = castDateToVarchar ? "cast(shipdate as varchar) as shipdate" : "shipdate";
String commitDate = castDateToVarchar ? "cast(commitdate as varchar) as commitdate" : "commitdate";
String receiptDate = castDateToVarchar ? "cast(receiptdate as varchar) as receiptdate" : "receiptdate";

queryRunner.execute("DROP TABLE IF EXISTS lineitem");
queryRunner.execute(session, "CREATE TABLE lineitem AS " +
"SELECT orderkey, partkey, suppkey, linenumber, quantity, extendedprice, discount, tax, " +
" returnflag, linestatus, cast(shipdate as varchar) as shipdate, cast(commitdate as varchar) as commitdate, " +
" cast(receiptdate as varchar) as receiptdate, shipinstruct, shipmode, comment " +
" returnflag, linestatus, " + shipDate + ", " + commitDate + ", " + receiptDate + ", " +
" shipinstruct, shipmode, comment " +
"FROM tpch.tiny.lineitem");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ extern "C" {
int64_t,
int64_t>("dynamic_custom_add");

facebook::presto::registerPrestoFunction<
custom::functionRegistry::CustomAdd,
int64_t,
int64_t,
int64_t>("custom_add");

facebook::presto::registerPrestoFunction<
custom::functionRegistry::SumArray,
int64_t,
Expand Down
Loading
Loading