Skip to content

SQL: Implement :: cast operator#38774

Merged
matriv merged 2 commits intoelastic:masterfrom
matriv:mt/fix-38717
Feb 12, 2019
Merged

SQL: Implement :: cast operator#38774
matriv merged 2 commits intoelastic:masterfrom
matriv:mt/fix-38717

Conversation

@matriv
Copy link
Copy Markdown
Contributor

@matriv matriv commented Feb 12, 2019

<expression>::<dataType> is a simplified altenative syntax to
`CAST( AS which exists in PostgreSQL and
provides an improved user experience and possibly more compact
SQL queries.

Fixes: #38717

`<expression>::<dataType>` is a simplified altenative syntax to
`CAST(<expression> AS <dataType> which exists in PostgreSQL and
provides an improved user experience and possibly more compact
SQL queries.

Fixes: elastic#38717
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-search

Copy link
Copy Markdown
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM

| '(' expression ')' #parenthesizedExpression
;

builtinDateTimeFunction
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why was the order changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just to have the cast/convert declarations next to each other.


public void testCastOperatorWithInvalidDataType() {
ParsingException ex = expectThrows(ParsingException.class, () -> parser.createExpression("-1::INVALID"));
assertEquals("line 1:6: Does not recognize type invalid", ex.getMessage());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The message needs improving - use "Does not recognize type [{}]", type.sourceText() - to preserve the original declaration inside visitPrimitiveDataType

Copy link
Copy Markdown
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@matriv matriv merged commit 526bb65 into elastic:master Feb 12, 2019
@matriv matriv deleted the mt/fix-38717 branch February 12, 2019 14:50
matriv added a commit that referenced this pull request Feb 12, 2019
`<expression>::<dataType>` is a simplified altenative syntax to
`CAST(<expression> AS <dataType> which exists in PostgreSQL and
provides an improved user experience and possibly more compact
SQL queries.

Fixes: #38717
@matriv
Copy link
Copy Markdown
Contributor Author

matriv commented Feb 12, 2019

Backported to 7.x with 032bcf9

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 13, 2019
* master:
  Remove _type term filters from cluster alert watches (elastic#38819)
  Adjust log and unmute testFailOverOnFollower (elastic#38762)
  Fix line separators in JSON logging tests (elastic#38771)
  Fix synchronization in LocalCheckpointTracker#contains (elastic#38755)
  muted test
  Remove TLSv1.2 pinning in ssl reload tests (elastic#38651)
  Don't fail init script if `/proc/.../max_map_count` absent (elastic#35933)
  Format Watcher.status.lastChecked and lastMetCondition (elastic#38626)
  SQL: Implement `::` cast operator (elastic#38774)
  Ignore failing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL: Implement postgres compatible :: cast operator

5 participants