Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add as of clause for SET and SELECT #1206

Merged
merged 11 commits into from
Apr 23, 2021
Merged

*: add as of clause for SET and SELECT #1206

merged 11 commits into from
Apr 23, 2021

Conversation

nolouch
Copy link
Member

@nolouch nolouch commented Apr 13, 2021

Signed-off-by: nolouch nolouch@gmail.com

What problem does this PR solve?

Ref pingcap/tidb#22765 (comment)

What is changed and how it works?

Check List

Tests

  • Unit test

@CLAassistant
Copy link

CLAassistant commented Apr 13, 2021

CLA assistant check
All committers have signed the CLA.

nolouch and others added 3 commits April 15, 2021 16:56
Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
parser_test.go Outdated Show resolved Hide resolved
Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch
Copy link
Member Author

nolouch commented Apr 16, 2021

Some details need to discuss pingcap/tidb#22765 (comment)

Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
Signed-off-by: nolouch <nolouch@gmail.com>
Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to use a TSO as the input to the AS OF clause?

select * from a as of timestamp 424430616285806594;
-- or?
select * from a as of tso 424430616285806594;

parser_test.go Show resolved Hide resolved
tangenta
tangenta previously approved these changes Apr 22, 2021
@ti-srebot ti-srebot added the status/LGT1 LGT1 label Apr 22, 2021
Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch
Copy link
Member Author

nolouch commented Apr 22, 2021

@kennytm Our TSO has some logic bits, not really Unix timestamp. if really have a scene TSO as input we can add it in the future.

@nolouch nolouch requested a review from Yisaer April 22, 2021 12:28
@kennytm
Copy link
Contributor

kennytm commented Apr 22, 2021

/lgtm

Our TSO has some logic bits, not really Unix timestamp. if really have a scene TSO as input we can add it in the future.

I'd like to note that @@tidb_snapshot can accept both the timestamp string and TSO. Also if READ_TS_IN calculates the output using resolvedTS it's natural for the function to return a TSO than a DATETIME(6).

@nolouch
Copy link
Member Author

nolouch commented Apr 23, 2021

If want tso as input, may we also support it in select * from a as of timestamp 424430616285806594?

@kennytm
Copy link
Contributor

kennytm commented Apr 23, 2021

/lgtm

@ti-srebot ti-srebot added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Apr 23, 2021
@kennytm kennytm merged commit f416dc9 into pingcap:master Apr 23, 2021
@nolouch nolouch deleted the asof branch April 23, 2021 06:07
@@ -5604,6 +5604,7 @@ func (checker *nodeTextCleaner) Enter(in ast.Node) (out ast.Node, skipChildren b
}
case *ast.FuncCallExpr:
node.FnName.O = strings.ToLower(node.FnName.O)
node.SetOriginTextPosition(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this line work for?

Copy link
Member Author

@nolouch nolouch Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's cleans the some text in the node, then we can use reflect.DeepEquals to compare two statements in :

parser/parser_test.go

Lines 388 to 391 in f416dc9

c.Assert(err, IsNil, comment)
CleanNodeText(stmt)
CleanNodeText(restoreStmt)
c.Assert(restoreStmt, DeepEquals, stmt, comment)

tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
* *: add as of clause

Signed-off-by: nolouch <nolouch@gmail.com>

* resolve shift-reduce conflict

* *: fix and try to add test

Signed-off-by: nolouch <nolouch@gmail.com>

* *: add timestamp

Signed-off-by: nolouch <nolouch@gmail.com>

* make as of to token

Signed-off-by: nolouch <nolouch@gmail.com>

* address comments

Signed-off-by: nolouch <nolouch@gmail.com>

* add test

Signed-off-by: nolouch <nolouch@gmail.com>

* make of as Reserved(from mysql 8.0)

Signed-off-by: nolouch <nolouch@gmail.com>

* add set test case

Signed-off-by: nolouch <nolouch@gmail.com>

* address comment

Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: tangenta <tangenta@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants