Skip to content
Closed
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e1609c7
Support script project pushdown
LantaoJin Jul 25, 2025
46e27ff
Merge remote-tracking branch 'upstream/main' into issues/3387
LantaoJin Jul 26, 2025
e563b5b
Fix IT
LantaoJin Jul 28, 2025
efef12c
Merge branch 'main' into pr/issues/3387
songkant-aws Sep 4, 2025
f197c4d
Resolve compile issue and use derived field script
songkant-aws Sep 9, 2025
c693625
Merge branch 'main' into project-pushdown
songkant-aws Sep 9, 2025
d6061e9
Fix derived field pushdown with correct project names and setup
songkant-aws Sep 9, 2025
65973d8
Fix pushed derived field name key conflicts with index fields issue
songkant-aws Sep 10, 2025
bb9cb2c
Merge branch 'main' into project-pushdown
songkant-aws Sep 11, 2025
688b5c9
Exclude some cases that are not supported
songkant-aws Sep 12, 2025
2794e1c
Merge branch 'main' into project-pushdown
songkant-aws Sep 12, 2025
34aa546
Exclude agg pushdown case after script project pushdown
songkant-aws Sep 12, 2025
5f1b61d
Refactor the code a bit
songkant-aws Sep 12, 2025
85f5b3e
Fix UT
songkant-aws Sep 12, 2025
c59f683
Merge branch 'main' into project-pushdown
songkant-aws Sep 17, 2025
80b5888
Revert some unnecessary change
songkant-aws Sep 17, 2025
33e2fb7
Merge branch 'main' into project-pushdown
songkant-aws Sep 18, 2025
9389e43
Merge pushDownProject and pushDownScriptPorject methods
songkant-aws Sep 17, 2025
ab7a5ce
Fix some bugs and correct explained plans
songkant-aws Sep 21, 2025
89837e1
Fix sort by simple expression after script project pushdown
songkant-aws Sep 21, 2025
e511b0b
Fix some logic for derived_existing fields
songkant-aws Sep 21, 2025
81739cb
Remove some unused methods
songkant-aws Sep 22, 2025
3642f10
Merge branch 'main' into project-pushdown
songkant-aws Sep 22, 2025
8056146
Fix spotless check
songkant-aws Sep 22, 2025
8f0af84
Add more test cases
songkant-aws Sep 23, 2025
c7e154b
Minor fixes to save script length
songkant-aws Sep 23, 2025
5e9ec59
Fix no pushdown IT
songkant-aws Sep 23, 2025
ec6ca9f
Merge branch 'main' into project-pushdown
songkant-aws Sep 24, 2025
b4815b4
Enable valid UDT type in script project pushdown
songkant-aws Sep 24, 2025
29882e9
Merge branch 'main' into project-pushdown
songkant-aws Oct 13, 2025
01e38a2
Merge branch 'main' into project-pushdown
songkant-aws Oct 13, 2025
9bc1fc3
Correct explained plans after merge
songkant-aws Oct 13, 2025
62827f4
Fix spotless check
songkant-aws Oct 13, 2025
68cd3c7
Support float type project pushdown
songkant-aws Oct 13, 2025
8210764
Fix expected result of testDivide
songkant-aws Oct 15, 2025
037476a
Merge branch 'main' into project-pushdown
songkant-aws Oct 15, 2025
1da8670
Address comments and relax pushdown row count factor
songkant-aws Oct 16, 2025
3f046f3
Fix explain cost test
songkant-aws Oct 16, 2025
3e501b2
Merge branch 'main' into project-pushdown
songkant-aws Oct 17, 2025
72d4481
Add more test cases
songkant-aws Oct 17, 2025
e36d38b
Transform test json files to yaml files
songkant-aws Oct 17, 2025
70afed0
Minor change to instantiate single instance of remap index visitor
songkant-aws Oct 17, 2025
bc91275
Add an IT to check query correctness
songkant-aws Oct 17, 2025
25e61d8
Fix spotless check
songkant-aws Oct 19, 2025
7b0032f
Merge branch 'main' into project-pushdown
songkant-aws Oct 21, 2025
da07146
Minor change of remapping expression in pushdownProject
songkant-aws Oct 21, 2025
e1dd9e7
Resolve conflicts after merge
songkant-aws Oct 22, 2025
2010ea8
Merge branch 'main' into project-pushdown
songkant-aws Oct 22, 2025
dd22241
Fix IT after merge
songkant-aws Oct 22, 2025
988a465
Add penalty cost if derived field script exceeds cap
songkant-aws Oct 23, 2025
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 @@ -33,22 +33,26 @@
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Predicate;
import lombok.Getter;
import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeSystem;
import org.apache.calcite.sql.SqlCollation;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.commons.lang3.tuple.Pair;
import org.opensearch.sql.calcite.type.AbstractExprRelDataType;
import org.opensearch.sql.calcite.type.ExprBinaryType;
import org.opensearch.sql.calcite.type.ExprDateType;
import org.opensearch.sql.calcite.type.ExprIPType;
import org.opensearch.sql.calcite.type.ExprSqlType;
import org.opensearch.sql.calcite.type.ExprTimeStampType;
import org.opensearch.sql.calcite.type.ExprTimeType;
import org.opensearch.sql.data.model.ExprValue;
Expand All @@ -68,6 +72,21 @@ private OpenSearchTypeFactory(RelDataTypeSystem typeSystem) {
super(typeSystem);
}

// Float is not supported well in OpenSearch core. See reported bug:
// https://github.com/opensearch-project/OpenSearch/issues/19271
private static final List<Pair<Predicate<RelDataType>, String>>
SUPPORTED_DSL_DERIVED_FIELD_TYPE_RULES =
Arrays.asList(
Pair.of(
t -> t instanceof ExprSqlType && ((ExprSqlType) t).getJavaType() == String.class,
"keyword"),
Pair.of(t -> SqlTypeName.INT_TYPES.contains(t.getSqlTypeName()), "long"),
// TODO: Support BigDecimal and other complex objects. A workaround is to wrap it in
// JSON object so that response can parse it
Pair.of(t -> SqlTypeName.DOUBLE.equals(t.getSqlTypeName()), "double"),
Pair.of(t -> SqlTypeName.BOOLEAN_TYPES.contains(t.getSqlTypeName()), "boolean"),
Pair.of(t -> SqlTypeName.CHAR_TYPES.contains(t.getSqlTypeName()), "keyword"));

@Getter
public enum ExprUDT {
EXPR_DATE(DATE),
Expand Down Expand Up @@ -337,4 +356,21 @@ public Type getJavaClass(RelDataType type) {
public static boolean isUserDefinedType(RelDataType type) {
return type instanceof AbstractExprRelDataType<?>;
}

public static boolean isTypeSupportedForDerivedField(RelDataType type) {
return SUPPORTED_DSL_DERIVED_FIELD_TYPE_RULES.stream()
.anyMatch(pair -> pair.getKey().test(type));
}

public static String convertRelDataTypeToSupportedDerivedFieldType(RelDataType type) {
return SUPPORTED_DSL_DERIVED_FIELD_TYPE_RULES.stream()
.filter(pair -> pair.getKey().test(type))
.findFirst()
.map(Pair::getValue)
.orElseThrow(
() ->
new IllegalArgumentException(
String.format(
Locale.ROOT, "Unsupported RelDataType for derived field: %s", type)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
Expand All @@ -26,6 +27,12 @@ public void init() throws Exception {
super.init();
loadIndex(Index.CLICK_BENCH);
disableCalcite();
setMaxScriptFields("hits", 100);
}

@After
public void afterTest() throws IOException {
resetMaxScriptFields("hits");
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public void testExplainRegexMatchInWhereWithScriptPushdown() throws IOException
}

@Test
public void testExplainRegexMatchInEvalWithOutScriptPushdown() throws IOException {
public void testExplainRegexMatchInEvalWithScriptPushdown() throws IOException {
enabledOnlyWhenPushdownIsEnabled();
String query =
String.format(
Expand Down Expand Up @@ -644,6 +644,21 @@ public void testRexExplain() throws IOException {
assertYamlEqualsJsonIgnoreId(expected, result);
}

@Test
public void testScriptProjectMultiplePush() throws IOException {
String expected = loadExpectedPlan("explain_script_project_multiple_push.json");
assertJsonEqualsIgnoreId(
expected,
explainQueryToString(
"source=opensearch-sql_test_index_account"
+ "| eval age2 = age + 2"
+ "| where age2 > 20"
+ "| eval upper_name = upper(firstname)"
+ "| where firstname = \\\"John\\\""
+ "| rex field=lastname \\\"(?<initial>^[A-Z])\\\""
+ "| fields age2, upper_name, initial, lastname"));
}

@Test
public void testExplainAppendCommand() throws IOException {
String expected = loadExpectedPlan("explain_append_command.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public abstract class SQLIntegTestCase extends OpenSearchSQLRestTestCase {
Integer.parseInt(System.getProperty("defaultQuerySizeLimit", "200"));
public static final Integer DEFAULT_MAX_RESULT_WINDOW =
Integer.parseInt(System.getProperty("defaultMaxResultWindow", "10000"));
public static final Integer DEFAULT_MAX_SCRIPT_FIELDS =
Integer.parseInt(System.getProperty("defaultMaxScriptFields", "32"));

public boolean shouldResetQuerySizeLimit() {
return true;
Expand Down Expand Up @@ -175,6 +177,15 @@ protected void resetMaxResultWindow(String indexName) throws IOException {
indexName, "{ \"index\": { \"max_result_window\": " + DEFAULT_MAX_RESULT_WINDOW + " } }");
}

protected void setMaxScriptFields(String indexName, Integer value) throws IOException {
updateIndexSettings(indexName, "{ \"index\": { \"max_script_fields\":" + value + " } }");
}

protected void resetMaxScriptFields(String indexName) throws IOException {
updateIndexSettings(
indexName, "{ \"index\": { \"max_script_fields\": " + DEFAULT_MAX_SCRIPT_FIELDS + " } }");
}

/** Provide for each test to load test index, data and other setup work */
protected void init() throws Exception {
disableCalcite();
Expand Down
38 changes: 38 additions & 0 deletions integ-test/src/test/java/org/opensearch/sql/ppl/ExplainIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,44 @@ public void testExplain() throws IOException {
+ "| fields age2"));
}

@Test
public void testScriptProjectPushDownExplain() throws IOException {
String expected = loadExpectedPlan("explain_script_project_push.json");
assertJsonEqualsIgnoreId(
expected,
explainQueryToString(
"source=opensearch-sql_test_index_account"
+ "| eval age2 = age + 2, upper_name = upper(firstname)"
+ "| fields age2, upper_name, firstname, lastname"));
}

@Test
public void testScriptProjectHasLiteralPartialPushDownExplain() throws IOException {
String expected = loadExpectedPlan("explain_script_project_has_literal_partial_push.json");
assertJsonEqualsIgnoreId(
expected,
explainQueryToString(
"source=opensearch-sql_test_index_account"
+ "| eval age2 = age + 2, upper_name = upper(firstname), age3 = 3"
+ "| fields age2, upper_name, gender, lastname, age3"));
}

// TODO: Optimize it with less scripts. For now, filter and two derived fields are all scripts.
// We can translate it to two derived script field with filter on the field result. Reduce from
// three scripts to two scripts with better cost computing logic
@Test
public void testScriptProjectPushDownWithFilterOnPushedFieldExplain() throws IOException {
String expected =
loadExpectedPlan("explain_script_project_push_with_filter_on_pushed_field.json");
assertJsonEqualsIgnoreId(
expected,
explainQueryToString(
"source=opensearch-sql_test_index_account"
+ "| eval age2 = age + 2, upper_name = upper(firstname)"
+ "| where age2 > 20"
+ "| fields age2, upper_name, firstname, lastname"));
}

@Test
public void testFilterPushDownExplain() throws IOException {
String expected = loadExpectedPlan("explain_filter_push.yaml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ calcite:
LogicalProject(category=[$1], value=[$2], timestamp=[$3], _id=[$4], _index=[$5], _score=[$6], _maxscore=[$7], _sort=[$8], _routing=[$9], @timestamp=[FROM_UNIXTIME(*(*(FLOOR(/(/(UNIX_TIMESTAMP($0), 3600), 2)), 2), 3600))])
CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_time_data]])
physical: |
EnumerableCalc(expr#0..3=[{inputs}], expr#4=[UNIX_TIMESTAMP($t3)], expr#5=[3600], expr#6=[/($t4, $t5)], expr#7=[2], expr#8=[/($t6, $t7)], expr#9=[FLOOR($t8)], expr#10=[*($t9, $t7)], expr#11=[*($t10, $t5)], expr#12=[FROM_UNIXTIME($t11)], proj#0..2=[{exprs}], $f3=[$t12])
CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_time_data]], PushDownContext=[[PROJECT->[category, value, timestamp, @timestamp], LIMIT->5, LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["category","value","timestamp","@timestamp"],"excludes":[]}}, requestedTotalSize=5, pageSize=null, startFrom=0)])
CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_time_data]], PushDownContext=[[PROJECT->[category, value, timestamp], SCRIPT_PROJECT->[@timestamp0], LIMIT->5, LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["category","value","timestamp"],"excludes":[]},"fields":[{"field":"@timestamp0"}],"derived":{"@timestamp0":{"type":"keyword","script":{"source":"{\"langType\":\"calcite\",\"script\":\"rO0ABXNyABFqYXZhLnV0aWwuQ29sbFNlcleOq7Y6G6gRAwABSQADdGFneHAAAAADdwQAAAAGdAAHcm93VHlwZXQAuHsKICAiZmllbGRzIjogWwogICAgewogICAgICAidWR0IjogIkVYUFJfVElNRVNUQU1QIiwKICAgICAgInR5cGUiOiAiVkFSQ0hBUiIsCiAgICAgICJudWxsYWJsZSI6IHRydWUsCiAgICAgICJwcmVjaXNpb24iOiAtMSwKICAgICAgIm5hbWUiOiAiQHRpbWVzdGFtcCIKICAgIH0KICBdLAogICJudWxsYWJsZSI6IGZhbHNlCn10AARleHBydAvWewogICJvcCI6IHsKICAgICJuYW1lIjogIkZST01fVU5JWFRJTUUiLAogICAgImtpbmQiOiAiT1RIRVJfRlVOQ1RJT04iLAogICAgInN5bnRheCI6ICJGVU5DVElPTiIKICB9LAogICJvcGVyYW5kcyI6IFsKICAgIHsKICAgICAgIm9wIjogewogICAgICAgICJuYW1lIjogIioiLAogICAgICAgICJraW5kIjogIlRJTUVTIiwKICAgICAgICAic3ludGF4IjogIkJJTkFSWSIKICAgICAgfSwKICAgICAgIm9wZXJhbmRzIjogWwogICAgICAgIHsKICAgICAgICAgICJvcCI6IHsKICAgICAgICAgICAgIm5hbWUiOiAiKiIsCiAgICAgICAgICAgICJraW5kIjogIlRJTUVTIiwKICAgICAgICAgICAgInN5bnRheCI6ICJCSU5BUlkiCiAgICAgICAgICB9LAogICAgICAgICAgIm9wZXJhbmRzIjogWwogICAgICAgICAgICB7CiAgICAgICAgICAgICAgIm9wIjogewogICAgICAgICAgICAgICAgIm5hbWUiOiAiRkxPT1IiLAogICAgICAgICAgICAgICAgImtpbmQiOiAiRkxPT1IiLAogICAgICAgICAgICAgICAgInN5bnRheCI6ICJGVU5DVElPTiIKICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICJvcGVyYW5kcyI6IFsKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgIm9wIjogewogICAgICAgICAgICAgICAgICAgICJuYW1lIjogIi8iLAogICAgICAgICAgICAgICAgICAgICJraW5kIjogIkRJVklERSIsCiAgICAgICAgICAgICAgICAgICAgInN5bnRheCI6ICJCSU5BUlkiCiAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICJvcGVyYW5kcyI6IFsKICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAib3AiOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICJuYW1lIjogIi8iLAogICAgICAgICAgICAgICAgICAgICAgICAia2luZCI6ICJESVZJREUiLAogICAgICAgICAgICAgICAgICAgICAgICAic3ludGF4IjogIkJJTkFSWSIKICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAib3BlcmFuZHMiOiBbCiAgICAgICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAib3AiOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAibmFtZSI6ICJVTklYX1RJTUVTVEFNUCIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAia2luZCI6ICJPVEhFUl9GVU5DVElPTiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAic3ludGF4IjogIkZVTkNUSU9OIgogICAgICAgICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgICAgICAgIm9wZXJhbmRzIjogWwogICAgICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiaW5wdXQiOiAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAibmFtZSI6ICIkMCIKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgICBdLAogICAgICAgICAgICAgICAgICAgICAgICAgICJjbGFzcyI6ICJvcmcub3BlbnNlYXJjaC5zcWwuZXhwcmVzc2lvbi5mdW5jdGlvbi5Vc2VyRGVmaW5lZEZ1bmN0aW9uQnVpbGRlciQxIiwKICAgICAgICAgICAgICAgICAgICAgICAgICAidHlwZSI6IHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICJ0eXBlIjogIkRPVUJMRSIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAibnVsbGFibGUiOiB0cnVlCiAgICAgICAgICAgICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgICAgICAgICAgICAgICAiZGV0ZXJtaW5pc3RpYyI6IHRydWUsCiAgICAgICAgICAgICAgICAgICAgICAgICAgImR5bmFtaWMiOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgImxpdGVyYWwiOiAzNjAwLAogICAgICAgICAgICAgICAgICAgICAgICAgICJ0eXBlIjogewogICAgICAgICAgICAgICAgICAgICAgICAgICAgInR5cGUiOiAiSU5URUdFUiIsCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAibnVsbGFibGUiOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgICAgXQogICAgICAgICAgICAgICAgICAgIH0sCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgImxpdGVyYWwiOiAyLAogICAgICAgICAgICAgICAgICAgICAgInR5cGUiOiB7CiAgICAgICAgICAgICAgICAgICAgICAgICJ0eXBlIjogIklOVEVHRVIiLAogICAgICAgICAgICAgICAgICAgICAgICAibnVsbGFibGUiOiBmYWxzZQogICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgXQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIF0KICAgICAgICAgICAgfSwKICAgICAgICAgICAgewogICAgICAgICAgICAgICJsaXRlcmFsIjogMiwKICAgICAgICAgICAgICAidHlwZSI6IHsKICAgICAgICAgICAgICAgICJ0eXBlIjogIklOVEVHRVIiLAogICAgICAgICAgICAgICAgIm51bGxhYmxlIjogZmFsc2UKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgIF0KICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgICJsaXRlcmFsIjogMzYwMCwKICAgICAgICAgICJ0eXBlIjogewogICAgICAgICAgICAidHlwZSI6ICJJTlRFR0VSIiwKICAgICAgICAgICAgIm51bGxhYmxlIjogZmFsc2UKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIF0KICAgIH0KICBdLAogICJjbGFzcyI6ICJvcmcub3BlbnNlYXJjaC5zcWwuZXhwcmVzc2lvbi5mdW5jdGlvbi5Vc2VyRGVmaW5lZEZ1bmN0aW9uQnVpbGRlciQxIiwKICAidHlwZSI6IHsKICAgICJ1ZHQiOiAiRVhQUl9USU1FU1RBTVAiLAogICAgInR5cGUiOiAiVkFSQ0hBUiIsCiAgICAibnVsbGFibGUiOiB0cnVlLAogICAgInByZWNpc2lvbiI6IC0xCiAgfSwKICAiZGV0ZXJtaW5pc3RpYyI6IHRydWUsCiAgImR5bmFtaWMiOiBmYWxzZQp9dAAKZmllbGRUeXBlc3NyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAABdAAKQHRpbWVzdGFtcHNyADpvcmcub3BlbnNlYXJjaC5zcWwub3BlbnNlYXJjaC5kYXRhLnR5cGUuT3BlblNlYXJjaERhdGVUeXBlni1SrhB9yq8CAAFMAAdmb3JtYXRzdAAQTGphdmEvdXRpbC9MaXN0O3hyADpvcmcub3BlbnNlYXJjaC5zcWwub3BlbnNlYXJjaC5kYXRhLnR5cGUuT3BlblNlYXJjaERhdGFUeXBlwmO8ygL6BTUCAANMAAxleHByQ29yZVR5cGV0ACtMb3JnL29wZW5zZWFyY2gvc3FsL2RhdGEvdHlwZS9FeHByQ29yZVR5cGU7TAALbWFwcGluZ1R5cGV0AEhMb3JnL29wZW5zZWFyY2gvc3FsL29wZW5zZWFyY2gvZGF0YS90eXBlL09wZW5TZWFyY2hEYXRhVHlwZSRNYXBwaW5nVHlwZTtMAApwcm9wZXJ0aWVzdAAPTGphdmEvdXRpbC9NYXA7eHB+cgApb3JnLm9wZW5zZWFyY2guc3FsLmRhdGEudHlwZS5FeHByQ29yZVR5cGUAAAAAAAAAABIAAHhyAA5qYXZhLmxhbmcuRW51bQAAAAAAAAAAEgAAeHB0AAlUSU1FU1RBTVB+cgBGb3JnLm9wZW5zZWFyY2guc3FsLm9wZW5zZWFyY2guZGF0YS50eXBlLk9wZW5TZWFyY2hEYXRhVHlwZSRNYXBwaW5nVHlwZQAAAAAAAAAAEgAAeHEAfgASdAAERGF0ZXNyADxzaGFkZWQuY29tLmdvb2dsZS5jb21tb24uY29sbGVjdC5JbW11dGFibGVNYXAkU2VyaWFsaXplZEZvcm0AAAAAAAAAAAIAAkwABGtleXN0ABJMamF2YS9sYW5nL09iamVjdDtMAAZ2YWx1ZXNxAH4AGXhwdXIAE1tMamF2YS5sYW5nLk9iamVjdDuQzlifEHMpbAIAAHhwAAAAAHVxAH4AGwAAAABzcQB+AAAAAAABdwQAAAAAeHh4\"}","lang":"opensearch_compounded_script","params":{"utcTimestamp": 0}}}}}, requestedTotalSize=5, pageSize=null, startFrom=0)])
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ calcite:
LogicalProject(account_number=[$0], firstname=[$1], address=[$2], balance=[$3], gender=[$4], city=[$5], employer=[$6], state=[$7], email=[$9], lastname=[$10], _id=[$11], _index=[$12], _score=[$13], _maxscore=[$14], _sort=[$15], _routing=[$16], age=[SPAN_BUCKET($8, 10)])
CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])
physical: |
EnumerableCalc(expr#0..10=[{inputs}], expr#11=[10], expr#12=[SPAN_BUCKET($t10, $t11)], proj#0..9=[{exprs}], $f10=[$t12])
CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]], PushDownContext=[[PROJECT->[account_number, firstname, address, balance, gender, city, employer, state, email, lastname, age], LIMIT->5, LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["account_number","firstname","address","balance","gender","city","employer","state","email","lastname","age"],"excludes":[]}}, requestedTotalSize=5, pageSize=null, startFrom=0)])
CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]], PushDownContext=[[PROJECT->[account_number, firstname, address, balance, gender, city, employer, state, email, lastname], SCRIPT_PROJECT->[age0], LIMIT->5, LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={"from":0,"size":5,"timeout":"1m","_source":{"includes":["account_number","firstname","address","balance","gender","city","employer","state","email","lastname"],"excludes":[]},"fields":[{"field":"age0"}],"derived":{"age0":{"type":"keyword","script":{"source":"{\"langType\":\"calcite\",\"script\":\"rO0ABXNyABFqYXZhLnV0aWwuQ29sbFNlcleOq7Y6G6gRAwABSQADdGFneHAAAAADdwQAAAAGdAAHcm93VHlwZXQAensKICAiZmllbGRzIjogWwogICAgewogICAgICAidHlwZSI6ICJCSUdJTlQiLAogICAgICAibnVsbGFibGUiOiB0cnVlLAogICAgICAibmFtZSI6ICJhZ2UiCiAgICB9CiAgXSwKICAibnVsbGFibGUiOiBmYWxzZQp9dAAEZXhwcnQB7HsKICAib3AiOiB7CiAgICAibmFtZSI6ICJTUEFOX0JVQ0tFVCIsCiAgICAia2luZCI6ICJPVEhFUl9GVU5DVElPTiIsCiAgICAic3ludGF4IjogIkZVTkNUSU9OIgogIH0sCiAgIm9wZXJhbmRzIjogWwogICAgewogICAgICAiaW5wdXQiOiAwLAogICAgICAibmFtZSI6ICIkMCIKICAgIH0sCiAgICB7CiAgICAgICJsaXRlcmFsIjogMTAsCiAgICAgICJ0eXBlIjogewogICAgICAgICJ0eXBlIjogIklOVEVHRVIiLAogICAgICAgICJudWxsYWJsZSI6IGZhbHNlCiAgICAgIH0KICAgIH0KICBdLAogICJjbGFzcyI6ICJvcmcub3BlbnNlYXJjaC5zcWwuZXhwcmVzc2lvbi5mdW5jdGlvbi5Vc2VyRGVmaW5lZEZ1bmN0aW9uQnVpbGRlciQxIiwKICAidHlwZSI6IHsKICAgICJ0eXBlIjogIlZBUkNIQVIiLAogICAgIm51bGxhYmxlIjogZmFsc2UsCiAgICAicHJlY2lzaW9uIjogMjAwMAogIH0sCiAgImRldGVybWluaXN0aWMiOiB0cnVlLAogICJkeW5hbWljIjogZmFsc2UKfXQACmZpZWxkVHlwZXNzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAAAXQAA2FnZX5yAClvcmcub3BlbnNlYXJjaC5zcWwuZGF0YS50eXBlLkV4cHJDb3JlVHlwZQAAAAAAAAAAEgAAeHIADmphdmEubGFuZy5FbnVtAAAAAAAAAAASAAB4cHQABExPTkd4eA==\"}","lang":"opensearch_compounded_script","params":{"utcTimestamp": 0}}}}}, requestedTotalSize=5, pageSize=null, startFrom=0)])
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"calcite": {
"logical": "LogicalSystemLimit(fetch=[10000], type=[QUERY_SIZE_LIMIT])\n LogicalProject(account_number=[$0], firstname=[$1], address=[$2], balance=[$3], gender=[$4], city=[$5], employer=[$6], state=[$7], age=[$8], email=[$9], lastname=[$10], new=[MAX(1, 2, 3, $8, 'banana':VARCHAR)])\n CalciteLogicalIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]])\n",
"physical": "EnumerableCalc(expr#0..10=[{inputs}], expr#11=[1], expr#12=[2], expr#13=[3], expr#14=['banana':VARCHAR], expr#15=[MAX($t11, $t12, $t13, $t8, $t14)], proj#0..10=[{exprs}], $f11=[$t15])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]], PushDownContext=[[PROJECT->[account_number, firstname, address, balance, gender, city, employer, state, age, email, lastname], LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\",\"_source\":{\"includes\":[\"account_number\",\"firstname\",\"address\",\"balance\",\"gender\",\"city\",\"employer\",\"state\",\"age\",\"email\",\"lastname\"],\"excludes\":[]}}, requestedTotalSize=10000, pageSize=null, startFrom=0)])\n"
"physical": "EnumerableCalc(expr#0..10=[{inputs}], expr#11=[1], expr#12=[2], expr#13=[3], expr#14=['banana':VARCHAR], expr#15=[MAX($t11, $t12, $t13, $t8, $t14)], proj#0..10=[{exprs}], new=[$t15])\n CalciteEnumerableIndexScan(table=[[OpenSearch, opensearch-sql_test_index_account]], PushDownContext=[[PROJECT->[account_number, firstname, address, balance, gender, city, employer, state, age, email, lastname], LIMIT->10000], OpenSearchRequestBuilder(sourceBuilder={\"from\":0,\"size\":10000,\"timeout\":\"1m\",\"_source\":{\"includes\":[\"account_number\",\"firstname\",\"address\",\"balance\",\"gender\",\"city\",\"employer\",\"state\",\"age\",\"email\",\"lastname\"],\"excludes\":[]}}, requestedTotalSize=10000, pageSize=null, startFrom=0)])\n"
}
}
Loading
Loading