Skip to content

Commit 8f2aaf8

Browse files
committed
planner: fix TPC-H's Q4 cannot be pushed down to TiFlash
1 parent 78c20a0 commit 8f2aaf8

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

pkg/planner/core/casetest/tpch/tpch_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,66 @@ CREATE TABLE lineitem (
143143
}
144144
}
145145

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+
146206
func TestQ9(t *testing.T) {
147207
store, dom := testkit.CreateMockStoreAndDomain(t)
148208
tk := testkit.NewTestKit(t, store)

pkg/planner/core/exhaust_physical_plans.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,6 +2703,9 @@ func exhaustPhysicalPlans4LogicalJoin(lp base.LogicalPlan, prop *property.Physic
27032703
failpoint.Return(indexJoins, true, nil)
27042704
}
27052705
})
2706+
if !lp.SCtx().GetSessionVars().InRestrictedSQL {
2707+
fmt.Println("wwz")
2708+
}
27062709

27072710
if !isJoinHintSupportedInMPPMode(p.PreferJoinType) {
27082711
if hasMPPJoinHints(p.PreferJoinType) {

0 commit comments

Comments
 (0)