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

SQL: Allow long literals #31777

Merged
merged 3 commits into from
Jul 5, 2018
Merged

SQL: Allow long literals #31777

merged 3 commits into from
Jul 5, 2018

Conversation

costin
Copy link
Member

@costin costin commented Jul 3, 2018

Fix bug that caused integral literals to be only Integer (rejecting
Long). This commit fixes that and picks either an Integer or Long based
on size.

Closes #31750

Fix bug that caused integral literals to be only Integer (rejecting
Long). This commit fixes that and picks either an Integer or Long based
on size.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

private final SqlParser parser = new SqlParser();

public void testLiteralLong() throws Exception {
Expression lt = parser.createExpression(String.valueOf(Long.MAX_VALUE));
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to test for things like +123 or -123 (having the +/- sign added to the String expression)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test for it (which uncovered an interesting case) - see below.

DATE_TO_BOOLEAN(fromDate(value -> value != 0));
DATE_TO_BOOLEAN(fromDate(value -> value != 0)),

BOOL_TO_LONG(fromBool(value -> value ? 1L : 0L));
Copy link
Member Author

Choose a reason for hiding this comment

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

My preference would be to move BOOL_TO_LONG up and start using it instead of BOOL_TO_INT for date conversions (we can't right now since the enum entry is defined after).
It's consistent and avoids the int to long conversion.

Copy link
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

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

LGTM

@davidkyle davidkyle added v6.3.2 and removed v6.3.1 labels Jul 5, 2018
@costin costin merged commit 07470c9 into elastic:master Jul 5, 2018
@costin costin deleted the fix-for-31750 branch July 5, 2018 17:07
costin added a commit that referenced this pull request Jul 5, 2018
Fix bug that caused integral literals to be only Integer (rejecting
Long). This commit fixes that and picks either an Integer or Long based
on size.

(cherry picked from commit 07470c9)
costin added a commit that referenced this pull request Jul 5, 2018
Fix bug that caused integral literals to be only Integer (rejecting
Long). This commit fixes that and picks either an Integer or Long based
on size.

(cherry picked from commit 07470c9)
(cherry picked from commit ab534e7)
dnhatn added a commit that referenced this pull request Jul 5, 2018
* 6.x:
  Test: Do not remove xpack templates when cleaning (#31642)
  SQL: Allow long literals (#31777)
  SQL: Fix incorrect message for aliases (#31792)
  Detach Transport from TransportService (#31727)
  6.3.1 release notes (#31829)
  Add unreleased version 6.3.2
  [ML][TEST] Use java 11 valid time format in DataDescriptionTests (#31817)
  [ML] Don't treat stale FAILED jobs as OPENING in job allocation (#31800)
  [ML] Fix calendar and filter updates from non-master nodes (#31804)
  Fix license header generation on Windows (#31790)
  mark XPackRestIT.test {p0=monitoring/bulk/10_basic/Bulk indexing of monitoring data} as AwaitsFix
  Add JDK11 support without enabling in CI (#31644)
  Watcher: Fix check for currently executed watches (#31137)
  [DOCS] Fixes 6.3.0 release notes (#31771)
  Watcher: Ensure correct method is used to read secure settings (#31753)
  [ML] Rate limit established model memory updates (#31768)
  SQL: Update CLI logo
dnhatn added a commit that referenced this pull request Jul 5, 2018
* master:
  REST high-level client: add get index API (#31703)
  SQL: Allow long literals (#31777)
  SQL: Fix incorrect message for aliases (#31792)
  Test: Do not remove xpack templates when cleaning (#31642)
  Reduce more raw types warnings (#31780)
  Add unreleased version 6.3.2
  Scripting: Remove support for deprecated StoredScript contexts (#31394)
  [ML][TEST] Use java 11 valid time format in DataDescriptionTests (#31817)
  [ML] Don't treat stale FAILED jobs as OPENING in job allocation (#31800)
  [ML] Fix calendar and filter updates from non-master nodes (#31804)
  Fix license header generation on Windows (#31790)
  mark RollupIT.testTwoJobsStartStopDeleteOne as AwaitsFix
  mark SearchAsyncActionTests.testFanOutAndCollect as AwaitsFix
  Correct exclusion of test on JDK 11
  Fix doclint jdk 11
  Add JDK11 support and enable in CI (#31644)
  Watcher: Fix check for currently executed watches (#31137)
  Watcher: Ensure correct method is used to read secure settings (#31753)
  SQL: Update CLI logo
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.

_xpack returned sql_illegal_argument_exception
7 participants