Skip to content

Commit 7b04566

Browse files
committed
Drop test tables to make CTE and other native tests run correctly
1 parent d270495 commit 7b04566

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,19 @@ public static void createLineitem(QueryRunner queryRunner)
109109

110110
public static void createLineitem(QueryRunner queryRunner, boolean castDateToVarchar)
111111
{
112-
if (!queryRunner.tableExists(queryRunner.getDefaultSession(), "lineitem")) {
113-
String shipDate = castDateToVarchar ? "cast(shipdate as varchar) as shipdate" : "shipdate";
114-
String commitDate = castDateToVarchar ? "cast(commitdate as varchar) as commitdate" : "commitdate";
115-
String receiptDate = castDateToVarchar ? "cast(receiptdate as varchar) as receiptdate" : "receiptdate";
116-
queryRunner.execute("CREATE TABLE lineitem AS " +
117-
"SELECT orderkey, partkey, suppkey, linenumber, quantity, extendedprice, discount, tax, " +
118-
" returnflag, linestatus, " + shipDate + ", " + commitDate + ", " + receiptDate + ", " +
119-
" shipinstruct, shipmode, comment, " +
120-
" linestatus = 'O' as is_open, returnflag = 'R' as is_returned, " +
121-
" cast(tax as real) as tax_as_real, cast(discount as real) as discount_as_real, " +
122-
" cast(linenumber as smallint) as linenumber_as_smallint, " +
123-
" cast(linenumber as tinyint) as linenumber_as_tinyint " +
124-
"FROM tpch.tiny.lineitem");
125-
}
112+
queryRunner.execute("DROP TABLE IF EXISTS lineitem");
113+
String shipDate = castDateToVarchar ? "cast(shipdate as varchar) as shipdate" : "shipdate";
114+
String commitDate = castDateToVarchar ? "cast(commitdate as varchar) as commitdate" : "commitdate";
115+
String receiptDate = castDateToVarchar ? "cast(receiptdate as varchar) as receiptdate" : "receiptdate";
116+
queryRunner.execute("CREATE TABLE lineitem AS " +
117+
"SELECT orderkey, partkey, suppkey, linenumber, quantity, extendedprice, discount, tax, " +
118+
" returnflag, linestatus, " + shipDate + ", " + commitDate + ", " + receiptDate + ", " +
119+
" shipinstruct, shipmode, comment, " +
120+
" linestatus = 'O' as is_open, returnflag = 'R' as is_returned, " +
121+
" cast(tax as real) as tax_as_real, cast(discount as real) as discount_as_real, " +
122+
" cast(linenumber as smallint) as linenumber_as_smallint, " +
123+
" cast(linenumber as tinyint) as linenumber_as_tinyint " +
124+
"FROM tpch.tiny.lineitem");
126125
}
127126

128127
public static void createLineitemForIceberg(QueryRunner queryRunner)
@@ -143,13 +142,12 @@ public static void createOrders(QueryRunner queryRunner)
143142

144143
public static void createOrders(QueryRunner queryRunner, boolean castDateToVarchar)
145144
{
146-
if (!queryRunner.tableExists(queryRunner.getDefaultSession(), "orders")) {
147-
String orderDate = castDateToVarchar ? "cast(orderdate as varchar) as orderdate" : "orderdate";
148-
queryRunner.execute("CREATE TABLE orders AS " +
149-
"SELECT orderkey, custkey, orderstatus, totalprice, " + orderDate + ", " +
150-
" orderpriority, clerk, shippriority, comment " +
151-
"FROM tpch.tiny.orders");
152-
}
145+
queryRunner.execute("DROP TABLE IF EXISTS orders");
146+
String orderDate = castDateToVarchar ? "cast(orderdate as varchar) as orderdate" : "orderdate";
147+
queryRunner.execute("CREATE TABLE orders AS " +
148+
"SELECT orderkey, custkey, orderstatus, totalprice, " + orderDate + ", " +
149+
" orderpriority, clerk, shippriority, comment " +
150+
"FROM tpch.tiny.orders");
153151
}
154152

155153
public static void createOrdersEx(QueryRunner queryRunner)

0 commit comments

Comments
 (0)