Skip to content
Closed
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 @@ -29,7 +29,7 @@ services:
discovery.type: "single-node"
ELASTICSEARCH_XPACK_SECURITY_ENABLED: "false"
volumes:
- ./data/es6/:/usr/share/elasticsearch/data
- ./data/es6/:/var/lib/elasticsearch/data
networks:
- doris--es
healthcheck:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"test1": "string1",
"test2": "text#1",
"test3": 3.14,
"test4": "2022-08-08"
"test4": "2022-08-08",
"test5": "2023-02-10 22:00:01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"test1": "string2",
"test2": "text2",
"test3": 4,
"test4": "2022-09-08"
"test4": "2022-09-08",
"test5": "2023-02-10 22:02:01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"test1": "string3",
"test2": "text3_4*5",
"test3": 5.0,
"test4": "2022-08-08"
"test4": "2022-08-08",
"test5": "2023-02-10 22:03:01"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"test1": "string4",
"test2": null,
"test3": 5.0,
"test4": "2023-02-10",
"test5": "2023-02-10 22:04:01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ curl "http://${ES_6_HOST}:9200/test2_20220808" -H "Content-Type:application/json
curl "http://${ES_6_HOST}:9200/test1/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_6_HOST}:9200/test1/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_6_HOST}:9200/test1/doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_6_HOST}:9200/test1/doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
curl "http://${ES_6_HOST}:9200/test2_20220808/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_6_HOST}:9200/test2_20220808/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_6_HOST}:9200/test2_20220808/doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_6_HOST}:9200/test2_20220808/doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'

# es7
# create index test1
Expand All @@ -39,9 +41,11 @@ curl "http://${ES_7_HOST}:9200/test2_20220808" -H "Content-Type:application/json
curl "http://${ES_7_HOST}:9200/test1/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_7_HOST}:9200/test1/_doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_7_HOST}:9200/test1/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_7_HOST}:9200/test1/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
curl "http://${ES_7_HOST}:9200/test2_20220808/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_7_HOST}:9200/test2_20220808/_doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_7_HOST}:9200/test2_20220808/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_7_HOST}:9200/test2_20220808/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'

# es8
# create index test1
Expand All @@ -52,6 +56,8 @@ curl "http://${ES_8_HOST}:9200/test2_20220808" -H "Content-Type:application/json
curl "http://${ES_8_HOST}:9200/test1/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_8_HOST}:9200/test1/_doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_8_HOST}:9200/test1/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_8_HOST}:9200/test1/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
curl "http://${ES_8_HOST}:9200/test2_20220808/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1.json'
curl "http://${ES_8_HOST}:9200/test2_20220808/_doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2.json'
curl "http://${ES_8_HOST}:9200/test2_20220808/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_8_HOST}:9200/test2_20220808/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@
"type": "double"
},
"test4": {
"type": "date"
"type": "date",
"format": "yyyy-MM-dd"
},
"test5": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"type": "double"
},
"test4": {
"type": "date"
"type": "date",
"format": "yyyy-MM-dd"
},
"test5": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
"type": "double"
},
"test4": {
"type": "date"
"type": "date",
"format": "yyyy-MM-dd"
},
"test5": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
"type": "double"
},
"test4": {
"type": "date"
"type": "date",
"format": "yyyy-MM-dd"
},
"test5": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ public static Type toDorisType(String esType) {
case "scaled_float":
return Type.DOUBLE;
case "date":
return ScalarType.createDateV2Type();
case "keyword":
case "text":
case "ip":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,8 @@ private PlanNode createScanNode(Analyzer analyzer, TableRef tblRef, SelectStmt s
throw new RuntimeException("Broker external table is not supported, try to use table function please");
case ELASTICSEARCH:
scanNode = new EsScanNode(ctx.getNextNodeId(), tblRef.getDesc(), "EsScanNode");
// push down limit to elasticsearch
scanNode.setLimit(selectStmt.getLimit() + selectStmt.getOffset());
break;
case HIVE:
throw new RuntimeException("Hive external table is not supported, try to use hive catalog please");
Expand All @@ -1961,6 +1963,8 @@ private PlanNode createScanNode(Analyzer analyzer, TableRef tblRef, SelectStmt s
break;
case ES_EXTERNAL_TABLE:
scanNode = new EsScanNode(ctx.getNextNodeId(), tblRef.getDesc(), "EsScanNode", true);
// push down limit to elasticsearch
scanNode.setLimit(selectStmt.getLimit() + selectStmt.getOffset());
break;
case JDBC_EXTERNAL_TABLE:
scanNode = new JdbcScanNode(ctx.getNextNodeId(), tblRef.getDesc(), true);
Expand Down
23 changes: 15 additions & 8 deletions regression-test/data/es_p0/test_es_query.out
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql62 --
2022-08-08 text#1 3.14 string1
2022-08-08T00:00:00.000Z 2023-02-10T22:00:01.000Z text#1 3.14 string1

-- !sql63 --
2022-08-08 text#1 3.14 string1
2022-08-08 text3_4*5 5.0 string3
2022-08-08T00:00:00.000Z 2023-02-10T22:00:01.000Z text#1 3.14 string1
2022-08-08T00:00:00.000Z 2023-02-10T22:03:01.000Z text3_4*5 5.0 string3

-- !sql64 --
2022-09-08 text2 4.0 string2
2022-09-08T00:00:00.000Z 2023-02-10T22:02:01.000Z text2 4.0 string2

-- !sql72 --
2022-08-08 text#1 3.14 string1
2022-08-08 2023-02-10 22:00:01 text#1 3.14 string1

-- !sql73 --
2022-08-08 text#1 3.14 string1
2022-08-08 text3_4*5 5.0 string3
2022-08-08 2023-02-10 22:00:01 text#1 3.14 string1
2022-08-08 2023-02-10 22:03:01 text3_4*5 5.0 string3

-- !sql74 --
2022-09-08 text2 4.0 string2
2022-09-08 2023-02-10 22:02:01 text2 4.0 string2

-- !sql81 --
2022-08-08 2023-02-10 22:00:01 text#1 3.14 string1

-- !sql82 --
2022-08-08 2023-02-10 22:00:01 text#1 3.14 string1
2022-08-08 2023-02-10 22:03:01 text3_4*5 5.0 string3

14 changes: 8 additions & 6 deletions regression-test/suites/es_p0/test_es_query.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ suite("test_es_query", "p0") {
order_qt_sql72 """select * from test1 where test2='text#1'"""
order_qt_sql73 """select * from test2_20220808 where test4='2022-08-08'"""
order_qt_sql74 """select * from test2_20220808 where substring(test2, 2) = 'ext2'"""
// es8 has some problem, need fix
// sql """switch es8"""
// order_qt_sql1 """select * from test1 where test2='text'"""
// order_qt_sql2 """select * from test2_20220808 where test4='2022-08-08'"""

sql """switch es8"""
order_qt_sql81 """select * from test1 where test2='text#1'"""
order_qt_sql82 """select * from test2_20220808 where test4='2022-08-08'"""
explain {
sql("select * from test1 order by test1 limit 2,2")
contains "limit: 4"
}
sql """drop catalog if exists es6;"""
sql """drop catalog if exists es7;"""
sql """drop catalog if exists es8;"""
sql """drop resource if exists es6_resource;"""
sql """drop resource if exists es7_resource;"""
sql """drop resource if exists es8_resource;"""
}
}
}