Skip to content

Commit

Permalink
[test](ES Catalog)Add mapping _routing test case (apache#42074)
Browse files Browse the repository at this point in the history
  • Loading branch information
qidaye authored Oct 22, 2024
1 parent 702b941 commit 6d23af2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ curl "http://${ES_5_HOST}:9200/test1" -H "Content-Type:application/json" -X PUT
curl "http://${ES_5_HOST}:9200/test2_20220808" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test2.json'
# create index test2_20220809
curl "http://${ES_5_HOST}:9200/test2_20220809" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test2.json'
# create index test3_20231005
curl "http://${ES_5_HOST}:9200/test3_20231005" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test3.json'
# put data for test1
curl "http://${ES_5_HOST}:9200/test1/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1_es6.json'
curl "http://${ES_5_HOST}:9200/test1/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2_es6.json'
Expand All @@ -62,6 +64,8 @@ curl "http://${ES_5_HOST}:9200/test2_20220808/doc/3" -H "Content-Type:applicatio
curl "http://${ES_5_HOST}:9200/test2_20220809/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1_es6.json'
curl "http://${ES_5_HOST}:9200/test2_20220809/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2_es6.json'
curl "http://${ES_5_HOST}:9200/test2_20220809/doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3_es5.json'
# put data for test3_20231005
curl "http://${ES_5_HOST}:9200/test3_20231005/doc/1?routing=my_routing_value" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'
# put _meta for array
curl "http://${ES_5_HOST}:9200/test1/doc/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
curl "http://${ES_5_HOST}:9200/test2_20220808/doc/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
Expand All @@ -85,6 +89,8 @@ curl "http://${ES_6_HOST}:9200/test1" -H "Content-Type:application/json" -X PUT
curl "http://${ES_6_HOST}:9200/test2_20220808" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test2.json'
# create index test2_20220809
curl "http://${ES_6_HOST}:9200/test2_20220809" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test2.json'
# create index test3_20231005
curl "http://${ES_6_HOST}:9200/test3_20231005" -H "Content-Type:application/json" -X PUT -d '@/mnt/scripts/index/es6_test3.json'
# put data for test1
curl "http://${ES_6_HOST}:9200/test1/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1_es6.json'
curl "http://${ES_6_HOST}:9200/test1/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2_es6.json'
Expand All @@ -98,6 +104,8 @@ curl "http://${ES_6_HOST}:9200/test2_20220808/doc/3" -H "Content-Type:applicatio
curl "http://${ES_6_HOST}:9200/test2_20220809/doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data1_es6.json'
curl "http://${ES_6_HOST}:9200/test2_20220809/doc/2" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data2_es6.json'
curl "http://${ES_6_HOST}:9200/test2_20220809/doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3_es6.json'
# put data for test3_20231005
curl "http://${ES_6_HOST}:9200/test3_20231005/doc/1?routing=my_routing_value" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'
# put _meta for array
curl "http://${ES_6_HOST}:9200/test1/doc/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
curl "http://${ES_6_HOST}:9200/test2_20220808/doc/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
Expand Down Expand Up @@ -139,7 +147,7 @@ curl "http://${ES_7_HOST}:9200/test2_20220809/_doc/2" -H "Content-Type:applicati
curl "http://${ES_7_HOST}:9200/test2_20220809/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_7_HOST}:9200/test2_20220809/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
# put data for test3_20231005
curl "http://${ES_7_HOST}:9200/test3_20231005/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'
curl "http://${ES_7_HOST}:9200/test3_20231005/_doc/1?routing=my_routing_value" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'

# put _meta for array
curl "http://${ES_7_HOST}:9200/test1/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
Expand Down Expand Up @@ -185,7 +193,7 @@ curl "http://${ES_8_HOST}:9200/test2_20220809/_doc/2" -H "Content-Type:applicati
curl "http://${ES_8_HOST}:9200/test2_20220809/_doc/3" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data3.json'
curl "http://${ES_8_HOST}:9200/test2_20220809/_doc/4" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data4.json'
# put data for test3_20231005
curl "http://${ES_8_HOST}:9200/test3_20231005/_doc/1" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'
curl "http://${ES_8_HOST}:9200/test3_20231005/_doc/1?routing=my_routing_value" -H "Content-Type:application/json" -X POST -d '@/mnt/scripts/data/data6.json'

# put _meta for array
curl "http://${ES_8_HOST}:9200/test1/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
Expand All @@ -199,4 +207,4 @@ bulk_request_file="/mnt/scripts/data/bulk_request_es8.json"
generate_bulk_request "composite_type_array" "" "item_" "$array_data_file" "$bulk_request_file"
curl -X POST "http://${ES_8_HOST}:9200/_bulk" --data-binary "@$bulk_request_file" -H "Content-Type: application/json"
# put _meta for composite_type_array
curl "http://${ES_8_HOST}:9200/composite_type_array/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta_composite_type_array.json"
curl "http://${ES_8_HOST}:9200/composite_type_array/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta_composite_type_array.json"
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"dynamic": "true",
"dynamic_date_formats": [
"strict_date_optional_time",
"yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
],
"dynamic_templates": [

],
"date_detection": true,
"numeric_detection": false,
"_routing": {
"required": true
},
"properties": {
"field1": { "type": "text" },
"field2": { "type": "keyword" }
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
],
"date_detection": true,
"numeric_detection": false,
"_routing": {
"required": true
},
"properties": {
"field1": { "type": "text" },
"field2": { "type": "keyword" }
Expand Down
12 changes: 12 additions & 0 deletions regression-test/data/external_table_p0/es/test_es_query.out
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ Grace [34, 56, 78] ["table tennis", "badminton", "athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]

-- !sql_5_28 --
value1 value2

-- !sql_6_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01 12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"] ["a", "b", "c"] [-1, 0, 1, 2] [{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128, 129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3] [{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] \N string1 text#1 3.14 2022-08-08T00:00 12345 2022-08-08T20:10:10

Expand Down Expand Up @@ -343,6 +346,9 @@ Grace [34, 56, 78] ["table tennis", "badminton", "athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]

-- !sql_6_28 --
value1 value2

-- !sql_7_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01 12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"] ["a", "b", "c"] [-1, 0, 1, 2] [{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128, 129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3] [{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] debug \N This string can be quite lengthy string1 2022-08-08T20:10:10 text#1 3.14 2022-08-08T00:00 2022-08-08T12:10:10 1659931810000 2022-08-08T12:10:10 2022-08-08T20:10:10 12345

Expand Down Expand Up @@ -897,6 +903,9 @@ Grace [34, 56, 78] ["table tennis", "badminton", "athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]

-- !sql_5_28 --
value1 value2

-- !sql_6_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01 12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"] ["a", "b", "c"] [-1, 0, 1, 2] [{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128, 129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3] [{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] \N string1 text#1 3.14 2022-08-08T00:00 12345 2022-08-08T20:10:10

Expand Down Expand Up @@ -1023,6 +1032,9 @@ Grace [34, 56, 78] ["table tennis", "badminton", "athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]

-- !sql_6_28 --
value1 value2

-- !sql_7_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01 12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"] ["a", "b", "c"] [-1, 0, 1, 2] [{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128, 129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3] [{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] debug \N This string can be quite lengthy string1 2022-08-08T20:10:10 text#1 3.14 2022-08-08T00:00 2022-08-08T12:10:10 1659931810000 2022-08-08T12:10:10 2022-08-08T20:10:10 12345

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ suite("test_es_query", "p0,external,es,external_docker,external_docker_es") {
order_qt_sql_5_25 """select test6 from test1;"""
order_qt_sql_5_26 """select test6 from test2;"""
order_qt_sql_5_27 """select * from composite_type_array order by name;"""
order_qt_sql_5_28 """select * from test3_20231005;"""

sql """switch test_es_query_es6"""
// order_qt_sql_6_01 """show tables"""
Expand Down Expand Up @@ -242,6 +243,7 @@ suite("test_es_query", "p0,external,es,external_docker,external_docker_es") {
order_qt_sql_6_25 """select test6 from test1;"""
order_qt_sql_6_26 """select test6 from test2;"""
order_qt_sql_6_27 """select * from composite_type_array order by name;"""
order_qt_sql_6_28 """select * from test3_20231005;"""

List<List<String>> tables6N = sql """show tables"""
boolean notContainHide = true
Expand Down

0 comments on commit 6d23af2

Please sign in to comment.