@@ -143,6 +143,66 @@ CREATE TABLE lineitem (
143
143
}
144
144
}
145
145
146
+ func TestQ4 (t * testing.T ) {
147
+ store , dom := testkit .CreateMockStoreAndDomain (t )
148
+ tk := testkit .NewTestKit (t , store )
149
+ tk .MustExec ("use test" )
150
+ tk .MustExec (`
151
+ CREATE TABLE orders (
152
+ O_ORDERKEY bigint NOT NULL,
153
+ O_CUSTKEY bigint NOT NULL,
154
+ O_ORDERSTATUS char(1) NOT NULL,
155
+ O_TOTALPRICE decimal(15,2) NOT NULL,
156
+ O_ORDERDATE date NOT NULL,
157
+ O_ORDERPRIORITY char(15) NOT NULL,
158
+ O_CLERK char(15) NOT NULL,
159
+ O_SHIPPRIORITY bigint NOT NULL,
160
+ O_COMMENT varchar(79) NOT NULL,
161
+ PRIMARY KEY (O_ORDERKEY) /*T![clustered_index] CLUSTERED */
162
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;` )
163
+ tk .MustExec (`
164
+ CREATE TABLE lineitem (
165
+ L_ORDERKEY bigint NOT NULL,
166
+ L_PARTKEY bigint NOT NULL,
167
+ L_SUPPKEY bigint NOT NULL,
168
+ L_LINENUMBER bigint NOT NULL,
169
+ L_QUANTITY decimal(15,2) NOT NULL,
170
+ L_EXTENDEDPRICE decimal(15,2) NOT NULL,
171
+ L_DISCOUNT decimal(15,2) NOT NULL,
172
+ L_TAX decimal(15,2) NOT NULL,
173
+ L_RETURNFLAG char(1) NOT NULL,
174
+ L_LINESTATUS char(1) NOT NULL,
175
+ L_SHIPDATE date NOT NULL,
176
+ L_COMMITDATE date NOT NULL,
177
+ L_RECEIPTDATE date NOT NULL,
178
+ L_SHIPINSTRUCT char(25) NOT NULL,
179
+ L_SHIPMODE char(10) NOT NULL,
180
+ L_COMMENT varchar(44) NOT NULL,
181
+ PRIMARY KEY (L_ORDERKEY, L_LINENUMBER) /*T![clustered_index] CLUSTERED */
182
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
183
+ ` )
184
+ testkit .SetTiFlashReplica (t , dom , "test" , "orders" )
185
+ testkit .SetTiFlashReplica (t , dom , "test" , "lineitem" )
186
+ //tk.MustExec(`set @@session.tidb_enforce_mpp=1;`)
187
+ tk .MustQuery (`explain format='cost_trace' select /*+ read_from_storage(tiflash[lineitem,orders]) */
188
+ o_orderpriority,
189
+ count(*) as order_count
190
+ from
191
+ orders
192
+ where
193
+ o_orderdate >= '1995-01-01'
194
+ and o_orderdate < date_add('1995-01-01', interval '3' month)
195
+ and exists (
196
+ select *
197
+ from
198
+ lineitem
199
+ where
200
+ l_orderkey = o_orderkey
201
+ and l_commitdate < l_receiptdate )
202
+ group by o_orderpriority
203
+ order by o_orderpriority` ).Check (testkit .Rows ())
204
+ }
205
+
146
206
func TestQ9 (t * testing.T ) {
147
207
store , dom := testkit .CreateMockStoreAndDomain (t )
148
208
tk := testkit .NewTestKit (t , store )
0 commit comments