Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
liugddx committed Sep 25, 2023
1 parent 3b9e5d0 commit a1fdc08
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ curl "http://${ES_6_HOST}:9200/test2_20220808/doc/3" -H "Content-Type:applicatio
# 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"
# create index .hide
curl "http://${ES_6_HOST}:9200/.hide" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/es6_hide.json"

# es7
# create index test1
Expand All @@ -54,6 +56,9 @@ curl "http://${ES_7_HOST}:9200/test2_20220808/_doc/4" -H "Content-Type:applicati
curl "http://${ES_7_HOST}:9200/test1/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"
curl "http://${ES_7_HOST}:9200/test2_20220808/_mapping" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/array_meta.json"

# create index .hide
curl "http://${ES_7_HOST}:9200/.hide" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/es7_hide.json"

# es8
# create index test1
curl "http://${ES_8_HOST}:9200/test1" -H "Content-Type:application/json" -X PUT -d "@/mnt/scripts/index/es7_test1.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"test1": {
"type": "keyword"
},
"test2": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"test3": {
"type": "double"
},
"test4": {
"type": "date"
},
"test5": {
"type": "long"
},
"c_bool": {
"type": "boolean"
},
"c_byte": {
"type": "byte"
},
"c_short": {
"type": "short"
},
"c_integer": {
"type": "integer"
},
"c_long": {
"type": "long"
},
"c_unsigned_long": {
"type": "unsigned_long"
},
"c_float": {
"type": "float"
},
"c_half_float": {
"type": "half_float"
},
"c_double": {
"type": "double"
},
"c_scaled_float": {
"type": "scaled_float",
"scaling_factor": 0.01
},
"c_date": {
"type": "date",
"format": "yyyy-MM-dd"
},
"c_datetime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"c_keyword": {
"type": "keyword"
},
"c_text": {
"type": "text"
},
"c_ip": {
"type": "ip"
},
"c_person": {
"properties": {
"name": {
"type": "keyword"
},
"age": {
"type": "integer"
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"test1": {
"type": "keyword"
},
"test2": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"test3": {
"type": "double"
},
"test4": {
"type": "date"
},
"test5": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"test6": {
"type": "date",
"format": "epoch_millis"
},
"test7": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss || epoch_millis"
},
"test8": {
"type": "date"
},
"test9": {
"type": "long"
},
"c_bool": {
"type": "boolean"
},
"c_byte": {
"type": "byte"
},
"c_short": {
"type": "short"
},
"c_integer": {
"type": "integer"
},
"c_long": {
"type": "long"
},
"c_unsigned_long": {
"type": "unsigned_long"
},
"c_float": {
"type": "float"
},
"c_half_float": {
"type": "half_float"
},
"c_double": {
"type": "double"
},
"c_scaled_float": {
"type": "scaled_float",
"scaling_factor": 0.01
},
"c_date": {
"type": "date",
"format": "yyyy-MM-dd"
},
"c_datetime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"c_keyword": {
"type": "keyword"
},
"c_text": {
"type": "text"
},
"c_ip": {
"type": "ip"
},
"c_person": {
"properties": {
"name": {
"type": "keyword"
},
"age": {
"type": "integer"
}
}
}
}
}
}
28 changes: 28 additions & 0 deletions regression-test/suites/external_table_p0/es/test_es_query.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ suite("test_es_query", "p0,external,es,external_docker,external_docker_es") {
);
"""

sql """create catalog if not exists es6_hide properties(
"type"="es",
"hosts"="http://${externalEnvIp}:$es_6_port",
"nodes_discovery"="false",
"enable_keyword_sniff"="true",
"include_hidden_index"="true"
);
"""

sql """create catalog if not exists es7_hide properties(
"type"="es",
"hosts"="http://${externalEnvIp}:$es_7_port",
"nodes_discovery"="false",
"enable_keyword_sniff"="true",
"include_hidden_index"="true"
);
"""

// test external table for datetime
sql """
CREATE TABLE `test_v1` (
Expand Down Expand Up @@ -148,6 +166,11 @@ suite("test_es_query", "p0,external,es,external_docker,external_docker_es") {
order_qt_sql67 """select * from test1 where esquery(test2, '{"match":{"test2":"text#1"}}')"""
order_qt_sql68 """select c_bool, c_byte, c_short, c_integer, c_long, c_unsigned_long, c_float, c_half_float, c_double, c_scaled_float, c_date, c_datetime, c_keyword, c_text, c_ip, c_person from test1"""
order_qt_sql69 """select c_bool, c_byte, c_short, c_integer, c_long, c_unsigned_long, c_float, c_half_float, c_double, c_scaled_float, c_date, c_datetime, c_keyword, c_text, c_ip, c_person from test2_20220808"""

sql """switch es6_hide"""
List<List<String>> tables6 = """show tables""" as List<List<String>>
assertTrue(tables6.get(0).contains(".hide"))

sql """switch es7"""
// order_qt_sql71 """show tables"""
order_qt_sql72 """select * from test1 where test2='text#1'"""
Expand All @@ -158,6 +181,11 @@ suite("test_es_query", "p0,external,es,external_docker,external_docker_es") {
order_qt_sql77 """select * from test1 where esquery(test2, '{"match":{"test2":"text#1"}}')"""
order_qt_sql78 """select c_bool, c_byte, c_short, c_integer, c_long, c_unsigned_long, c_float, c_half_float, c_double, c_scaled_float, c_date, c_datetime, c_keyword, c_text, c_ip, c_person from test1"""
order_qt_sql79 """select c_bool, c_byte, c_short, c_integer, c_long, c_unsigned_long, c_float, c_half_float, c_double, c_scaled_float, c_date, c_datetime, c_keyword, c_text, c_ip, c_person from test2"""

sql """switch es7_hide"""
List<List<String>> tables7 = """show tables""" as List<List<String>>
assertTrue(tables7.get(0).contains(".hide"))

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 00:00:00' and test4 < '2022-08-08 23:59:59'"""
Expand Down

0 comments on commit a1fdc08

Please sign in to comment.