Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@

@EqualsAndHashCode
public class ExprBooleanValue implements ExprValue {
private static final ExprValue TRUE = new ExprBooleanValue(true);
private static final ExprValue FALSE = new ExprBooleanValue(false);
private static final ExprBooleanValue TRUE = new ExprBooleanValue(true);
private static final ExprBooleanValue FALSE = new ExprBooleanValue(false);

private final Boolean value;

private ExprBooleanValue(Boolean value) {
this.value = value;
}

public static ExprValue ofTrue() {
return TRUE;
}

public static ExprValue ofFalse() {
return FALSE;
public static ExprBooleanValue of(Boolean value) {
return value ? TRUE : FALSE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
*/
@UtilityClass
public class ExprValueUtils {
public static final ExprValue LITERAL_TRUE = ExprBooleanValue.ofTrue();
public static final ExprValue LITERAL_FALSE = ExprBooleanValue.ofFalse();
public static final ExprValue LITERAL_TRUE = ExprBooleanValue.of(true);
public static final ExprValue LITERAL_FALSE = ExprBooleanValue.of(false);
public static final ExprValue LITERAL_NULL = ExprNullValue.of();
public static final ExprValue LITERAL_MISSING = ExprMissingValue.of();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void visitShouldReturnDefaultPhysicalOperator() {
ReferenceExpression include = ref("age", INTEGER);
ReferenceExpression exclude = ref("name", STRING);
ReferenceExpression dedupeField = ref("name", STRING);
Expression filterExpr = literal(ExprBooleanValue.ofTrue());
Expression filterExpr = literal(ExprBooleanValue.of(true));
List<Expression> groupByExprs = Arrays.asList(ref("age", INTEGER));
List<Aggregator> aggregators =
Arrays.asList(new AvgAggregator(groupByExprs, ExprCoreType.DOUBLE));
Expand Down
28 changes: 14 additions & 14 deletions docs/experiment/ppl/cmd/search.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ PPL query::

od> source=accounts;
fetched rows / total rows = 4/4
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
| account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname |
|------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------|
| 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke |
| 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond |
| 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates |
| 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams |
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+
| account_number | balance | firstname | lastname | age | gender | address | employer | email | city | state |
|------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------|
| 1 | 39225 | Amber | Duke | 32 | M | 880 Holmes Lane | Pyrami | amberduke@pyrami.com | Brogan | IL |
| 6 | 5686 | Hattie | Bond | 36 | M | 671 Bristol Street | Netagy | hattiebond@netagy.com | Dante | TN |
| 13 | 32838 | Nanette | Bates | 28 | F | 789 Madison Street | Quility | null | Nogal | VA |
| 18 | 4180 | Dale | Adams | 33 | M | 467 Hutchinson Court | null | daleadams@boink.com | Orick | MD |
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+

Example 2: Fetch data with condition
====================================
Expand All @@ -50,10 +50,10 @@ PPL query::

od> source=accounts account_number=1 or gender="F";
fetched rows / total rows = 2/2
+------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+
| account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname |
|------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------|
| 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke |
| 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates |
+------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+
+------------------+-----------+-------------+------------+-------+----------+--------------------+------------+----------------------+--------+---------+
| account_number | balance | firstname | lastname | age | gender | address | employer | email | city | state |
|------------------+-----------+-------------+------------+-------+----------+--------------------+------------+----------------------+--------+---------|
| 1 | 39225 | Amber | Duke | 32 | M | 880 Holmes Lane | Pyrami | amberduke@pyrami.com | Brogan | IL |
| 13 | 32838 | Nanette | Bates | 28 | F | 789 Madison Street | Quility | null | Nogal | VA |
+------------------+-----------+-------------+------------+-------+----------+--------------------+------------+----------------------+--------+---------+

14 changes: 7 additions & 7 deletions docs/experiment/ppl/cmd/where.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ The example show fetch all the document from accounts index with .

PPL query::

od> source=accounts | where account_number=1 or gender="F";
od> source=accounts | where account_number=1 or gender="F" | fields account_number, gender;
fetched rows / total rows = 2/2
+------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+
| account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname |
|------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------|
| 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke |
| 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates |
+------------------+-------------+--------------------+-----------+----------+--------+------------+---------+-------+----------------------+------------+
+------------------+----------+
| account_number | gender |
|------------------+----------|
| 1 | M |
| 13 | F |
+------------------+----------+

32 changes: 16 additions & 16 deletions docs/user/general/identifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Here are examples for using index pattern directly without quotes::

od> SELECT * FROM *cc*nt*;
fetched rows / total rows = 4/4
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
| account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname |
|------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------|
| 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke |
| 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond |
| 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates |
| 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams |
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+
| account_number | balance | firstname | lastname | age | gender | address | employer | email | city | state |
|------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------|
| 1 | 39225 | Amber | Duke | 32 | M | 880 Holmes Lane | Pyrami | amberduke@pyrami.com | Brogan | IL |
| 6 | 5686 | Hattie | Bond | 36 | M | 671 Bristol Street | Netagy | hattiebond@netagy.com | Dante | TN |
| 13 | 32838 | Nanette | Bates | 28 | F | 789 Madison Street | Quility | null | Nogal | VA |
| 18 | 4180 | Dale | Adams | 33 | M | 467 Hutchinson Court | null | daleadams@boink.com | Orick | MD |
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+


Delimited Identifiers
Expand Down Expand Up @@ -76,14 +76,14 @@ Here are examples for quoting an index name by back ticks::

od> SELECT * FROM `accounts`;
fetched rows / total rows = 4/4
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
| account_number | firstname | address | balance | gender | city | employer | state | age | email | lastname |
|------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------|
| 1 | Amber | 880 Holmes Lane | 39225 | M | Brogan | Pyrami | IL | 32 | amberduke@pyrami.com | Duke |
| 6 | Hattie | 671 Bristol Street | 5686 | M | Dante | Netagy | TN | 36 | hattiebond@netagy.com | Bond |
| 13 | Nanette | 789 Madison Street | 32838 | F | Nogal | Quility | VA | 28 | null | Bates |
| 18 | Dale | 467 Hutchinson Court | 4180 | M | Orick | null | MD | 33 | daleadams@boink.com | Adams |
+------------------+-------------+----------------------+-----------+----------+--------+------------+---------+-------+-----------------------+------------+
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+
| account_number | balance | firstname | lastname | age | gender | address | employer | email | city | state |
|------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------|
| 1 | 39225 | Amber | Duke | 32 | M | 880 Holmes Lane | Pyrami | amberduke@pyrami.com | Brogan | IL |
| 6 | 5686 | Hattie | Bond | 36 | M | 671 Bristol Street | Netagy | hattiebond@netagy.com | Dante | TN |
| 13 | 32838 | Nanette | Bates | 28 | F | 789 Madison Street | Quility | null | Nogal | VA |
| 18 | 4180 | Dale | Adams | 33 | M | 467 Hutchinson Court | null | daleadams@boink.com | Orick | MD |
+------------------+-----------+-------------+------------+-------+----------+----------------------+------------+-----------------------+--------+---------+


Case Sensitivity
Expand Down
2 changes: 2 additions & 0 deletions elasticsearch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies {
compile group: 'org.elasticsearch', name: 'elasticsearch', version: "${es_version}"
compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: "${es_version}"
compile "io.github.resilience4j:resilience4j-retry:1.5.0"
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.10.4'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.4'

testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*
*/

package com.amazon.opendistroforelasticsearch.sql.elasticsearch.data.value;

import static java.time.temporal.ChronoField.DAY_OF_MONTH;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoField.NANO_OF_SECOND;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;

import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.format.ResolverStyle;
import java.time.format.SignStyle;
import java.time.temporal.ChronoField;
import java.util.Locale;
import lombok.experimental.UtilityClass;

/**
* DateTimeFormatter.
* Reference org.elasticsearch.common.time.DateFormatters.
*/
@UtilityClass
public class ElasticsearchDateFormatters {

public static final DateTimeFormatter TIME_ZONE_FORMATTER_NO_COLON =
new DateTimeFormatterBuilder()
.appendOffset("+HHmm", "Z")
.toFormatter(Locale.ROOT)
.withResolverStyle(ResolverStyle.STRICT);

public static final DateTimeFormatter STRICT_YEAR_MONTH_DAY_FORMATTER =
new DateTimeFormatterBuilder()
.appendValue(ChronoField.YEAR, 4, 10, SignStyle.EXCEEDS_PAD)
.optionalStart()
.appendLiteral("-")
.appendValue(MONTH_OF_YEAR, 2, 2, SignStyle.NOT_NEGATIVE)
.optionalStart()
.appendLiteral('-')
.appendValue(DAY_OF_MONTH, 2, 2, SignStyle.NOT_NEGATIVE)
.optionalEnd()
.optionalEnd()
.toFormatter(Locale.ROOT)
.withResolverStyle(ResolverStyle.STRICT);

public static final DateTimeFormatter STRICT_DATE_OPTIONAL_TIME_FORMATTER =
new DateTimeFormatterBuilder()
.append(STRICT_YEAR_MONTH_DAY_FORMATTER)
.optionalStart()
.appendLiteral('T')
.optionalStart()
.appendValue(HOUR_OF_DAY, 2, 2, SignStyle.NOT_NEGATIVE)
.optionalStart()
.appendLiteral(':')
.appendValue(MINUTE_OF_HOUR, 2, 2, SignStyle.NOT_NEGATIVE)
.optionalStart()
.appendLiteral(':')
.appendValue(SECOND_OF_MINUTE, 2, 2, SignStyle.NOT_NEGATIVE)
.optionalStart()
.appendFraction(NANO_OF_SECOND, 1, 9, true)
.optionalEnd()
.optionalStart()
.appendLiteral(',')
.appendFraction(NANO_OF_SECOND, 1, 9, false)
.optionalEnd()
.optionalEnd()
.optionalEnd()
.optionalStart()
.appendZoneOrOffsetId()
.optionalEnd()
.optionalStart()
.append(TIME_ZONE_FORMATTER_NO_COLON)
.optionalEnd()
.optionalEnd()
.optionalEnd()
.toFormatter(Locale.ROOT)
.withResolverStyle(ResolverStyle.STRICT);

public static final DateTimeFormatter SQL_LITERAL_DATE_TIME_FORMAT = DateTimeFormatter
.ofPattern("yyyy-MM-dd HH:mm:ss");
}
Loading