pingcap / pingcap/tiflash

date_sub(date, interval Expression week) shouldn't return datetime type result

Open
#3,969 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/compute severity/minor type/bug
Dominant language
C++
Stars
1k
Forks
423
Avg merge
1d 15h
Merged PRs (30d)
24

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)
create table t(a date);
alter table t set tiflash replica 1;
insert into t values("2020-10-10");
set tidb_enforce_mpp=1;
select date_sub(a, interval 1 week) from t; -- expect "2020-10-03" but got "2020-10-03 00:00:00.000000"
/*
+---------------------------+---------+--------------+---------------+--------------------------------------------+
| id                        | estRows | task         | access object | operator info                              |
+---------------------------+---------+--------------+---------------+--------------------------------------------+
| TableReader_9             | 1.00    | root         |               | data:ExchangeSender_8                      |
| └─ExchangeSender_8        | 1.00    | cop[tiflash] |               | ExchangeType: PassThrough                  |
|   └─Projection_4          | 1.00    | cop[tiflash] |               | date_sub(pushdown2.t.a, 1, WEEK)->Column#3 |
|     └─TableFullScan_7     | 1.00    | cop[tiflash] | table:t       | keep order:false, stats:pseudo             |
+---------------------------+---------+--------------+---------------+--------------------------------------------+
*/
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiFlash version? (Required)

master

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided SQL reproduction in TiFlash, focusing on the date_sub expression with a DATE column and a WEEK interval under TiFlash MPP execution. Trace where the expression's result type is determined and verify the query result against the expected DATE value without a time component.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.