@@ -55,10 +55,10 @@ class TrinoRunner implements BenchmarkRunner {
5555 // This is query 15
5656 let [ createView , query , dropView ] = sql . split ( ";" )
5757 await this . executeSingleStatement ( createView ) ;
58- response = await this . executeSingleStatement ( query ) ;
58+ response = await this . executeSingleStatement ( `EXPLAIN ANALYZE ${ query } ` ) ; // Use EXPLAIN ANALYZE for the actual query
5959 await this . executeSingleStatement ( dropView ) ;
6060 } else {
61- response = await this . executeSingleStatement ( sql )
61+ response = await this . executeSingleStatement ( `EXPLAIN ANALYZE ${ sql } ` )
6262 }
6363
6464 return response
@@ -97,7 +97,15 @@ class TrinoRunner implements BenchmarkRunner {
9797
9898 // Count rows if data is present
9999 if ( result . data ) {
100- rowCount += result . data . length ;
100+ if ( typeof result . data ?. [ 0 ] ?. [ 0 ] === 'string' ) {
101+ // Extract row count from EXPLAIN ANALYZE output
102+ const outputMatch = result . data [ 0 ] [ 0 ] . match ( / O u t p u t .* ?( \d + ) \s + r o w s / i) ;
103+ if ( outputMatch ) {
104+ rowCount = parseInt ( outputMatch [ 1 ] ) ;
105+ }
106+ } else {
107+ rowCount += result . data . length ;
108+ }
101109 }
102110
103111 // Check for errors
@@ -113,123 +121,123 @@ class TrinoRunner implements BenchmarkRunner {
113121 const schema = `tpch_sf${ sf } ` ;
114122
115123 // Create schema first
116- await this . executeQuery ( `CREATE SCHEMA IF NOT EXISTS hive.${ schema } WITH (location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /')` ) ;
124+ await this . executeSingleStatement ( `CREATE SCHEMA IF NOT EXISTS hive.${ schema } WITH (location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /')` ) ;
117125
118126 // Create customer table
119- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .customer` ) ;
120- await this . executeQuery ( `CREATE TABLE hive.${ schema } .customer
121- (
122- c_custkey bigint,
123- c_name varchar(25),
124- c_address varchar(40),
125- c_nationkey bigint,
126- c_phone varchar(15),
127- c_acctbal decimal(15, 2),
128- c_mktsegment varchar(10),
129- c_comment varchar(117)
130- )
127+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .customer` ) ;
128+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .customer
129+ (
130+ c_custkey bigint,
131+ c_name varchar(25),
132+ c_address varchar(40),
133+ c_nationkey bigint,
134+ c_phone varchar(15),
135+ c_acctbal decimal(15, 2),
136+ c_mktsegment varchar(10),
137+ c_comment varchar(117)
138+ )
131139 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /customer/', format = 'PARQUET')` ) ;
132140
133141 // Create lineitem table
134- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .lineitem` ) ;
135- await this . executeQuery ( `CREATE TABLE hive.${ schema } .lineitem
136- (
137- l_orderkey bigint,
138- l_partkey bigint,
139- l_suppkey bigint,
140- l_linenumber integer,
141- l_quantity decimal(15, 2),
142- l_extendedprice decimal(15, 2),
143- l_discount decimal(15, 2),
144- l_tax decimal(15, 2),
145- l_returnflag varchar(1),
146- l_linestatus varchar(1),
147- l_shipdate date,
148- l_commitdate date,
149- l_receiptdate date,
150- l_shipinstruct varchar(25),
151- l_shipmode varchar(10),
152- l_comment varchar(44)
153- )
142+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .lineitem` ) ;
143+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .lineitem
144+ (
145+ l_orderkey bigint,
146+ l_partkey bigint,
147+ l_suppkey bigint,
148+ l_linenumber integer,
149+ l_quantity decimal(15, 2),
150+ l_extendedprice decimal(15, 2),
151+ l_discount decimal(15, 2),
152+ l_tax decimal(15, 2),
153+ l_returnflag varchar(1),
154+ l_linestatus varchar(1),
155+ l_shipdate date,
156+ l_commitdate date,
157+ l_receiptdate date,
158+ l_shipinstruct varchar(25),
159+ l_shipmode varchar(10),
160+ l_comment varchar(44)
161+ )
154162 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /lineitem/', format = 'PARQUET')` ) ;
155163
156164 // Create nation table
157- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .nation` ) ;
158- await this . executeQuery ( `CREATE TABLE hive.${ schema } .nation
159- (
160- n_nationkey bigint,
161- n_name varchar(25),
162- n_regionkey bigint,
163- n_comment varchar(152)
164- )
165+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .nation` ) ;
166+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .nation
167+ (
168+ n_nationkey bigint,
169+ n_name varchar(25),
170+ n_regionkey bigint,
171+ n_comment varchar(152)
172+ )
165173 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /nation/', format = 'PARQUET')` ) ;
166174
167175 // Create orders table
168- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .orders` ) ;
169- await this . executeQuery ( `CREATE TABLE hive.${ schema } .orders
170- (
171- o_orderkey bigint,
172- o_custkey bigint,
173- o_orderstatus varchar(1),
174- o_totalprice decimal(15, 2),
175- o_orderdate date,
176- o_orderpriority varchar(15),
177- o_clerk varchar(15),
178- o_shippriority integer,
179- o_comment varchar(79)
180- )
176+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .orders` ) ;
177+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .orders
178+ (
179+ o_orderkey bigint,
180+ o_custkey bigint,
181+ o_orderstatus varchar(1),
182+ o_totalprice decimal(15, 2),
183+ o_orderdate date,
184+ o_orderpriority varchar(15),
185+ o_clerk varchar(15),
186+ o_shippriority integer,
187+ o_comment varchar(79)
188+ )
181189 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /orders/', format = 'PARQUET')` ) ;
182190
183191 // Create part table
184- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .part` ) ;
185- await this . executeQuery ( `CREATE TABLE hive.${ schema } .part
186- (
187- p_partkey bigint,
188- p_name varchar(55),
189- p_mfgr varchar(25),
190- p_brand varchar(10),
191- p_type varchar(25),
192- p_size integer,
193- p_container varchar(10),
194- p_retailprice decimal(15, 2),
195- p_comment varchar(23)
196- )
192+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .part` ) ;
193+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .part
194+ (
195+ p_partkey bigint,
196+ p_name varchar(55),
197+ p_mfgr varchar(25),
198+ p_brand varchar(10),
199+ p_type varchar(25),
200+ p_size integer,
201+ p_container varchar(10),
202+ p_retailprice decimal(15, 2),
203+ p_comment varchar(23)
204+ )
197205 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /part/', format = 'PARQUET')` ) ;
198206
199207 // Create partsupp table
200- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .partsupp` ) ;
201- await this . executeQuery ( `CREATE TABLE hive.${ schema } .partsupp
202- (
203- ps_partkey bigint,
204- ps_suppkey bigint,
205- ps_availqty integer,
206- ps_supplycost decimal(15, 2),
207- ps_comment varchar(199)
208- )
208+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .partsupp` ) ;
209+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .partsupp
210+ (
211+ ps_partkey bigint,
212+ ps_suppkey bigint,
213+ ps_availqty integer,
214+ ps_supplycost decimal(15, 2),
215+ ps_comment varchar(199)
216+ )
209217 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /partsupp/', format = 'PARQUET')` ) ;
210218
211219 // Create region table
212- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .region` ) ;
213- await this . executeQuery ( `CREATE TABLE hive.${ schema } .region
214- (
215- r_regionkey bigint,
216- r_name varchar(25),
217- r_comment varchar(152)
218- )
220+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .region` ) ;
221+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .region
222+ (
223+ r_regionkey bigint,
224+ r_name varchar(25),
225+ r_comment varchar(152)
226+ )
219227 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /region/', format = 'PARQUET')` ) ;
220228
221229 // Create supplier table
222- await this . executeQuery ( `DROP TABLE IF EXISTS hive.${ schema } .supplier` ) ;
223- await this . executeQuery ( `CREATE TABLE hive.${ schema } .supplier
224- (
225- s_suppkey bigint,
226- s_name varchar(25),
227- s_address varchar(40),
228- s_nationkey bigint,
229- s_phone varchar(15),
230- s_acctbal decimal(15, 2),
231- s_comment varchar(101)
232- )
230+ await this . executeSingleStatement ( `DROP TABLE IF EXISTS hive.${ schema } .supplier` ) ;
231+ await this . executeSingleStatement ( `CREATE TABLE hive.${ schema } .supplier
232+ (
233+ s_suppkey bigint,
234+ s_name varchar(25),
235+ s_address varchar(40),
236+ s_nationkey bigint,
237+ s_phone varchar(15),
238+ s_acctbal decimal(15, 2),
239+ s_comment varchar(101)
240+ )
233241 WITH (external_location = 's3://datafusion-distributed-benchmarks/tpch_sf${ sf } /supplier/', format = 'PARQUET')` ) ;
234242 }
235243}
0 commit comments