This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new 33a7d1e2c9 [branch-1.2](test) fix some test case on branch 1.2 (#18294)
33a7d1e2c9 is described below
commit 33a7d1e2c906459fe87decc1105136a92153d4bc
Author: Mingyu Chen <[email protected]>
AuthorDate: Fri Mar 31 23:26:31 2023 +0800
[branch-1.2](test) fix some test case on branch 1.2 (#18294)
1. outfile test case
2. remove nereids test case
---
.../org/apache/doris/analysis/OutFileClause.java | 2 -
.../bitmap_functions/test_bitmap_function.out | 447 --------------
.../query_p0/group_concat/test_group_concat.out | 1 -
.../suites/export/test_array_export.groovy | 9 +
.../suites/export_p0/test_outfile.groovy | 86 +--
.../suites/export_p0/test_outfile_expr.groovy | 39 +-
.../suites/export_p0/test_outfile_parquet.groovy | 40 +-
.../suites/export_p0/test_outfile_separator.groovy | 44 +-
.../bitmap_functions/test_bitmap_function.groovy | 640 ---------------------
9 files changed, 95 insertions(+), 1213 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
index 78f57cff9c..f538353965 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/OutFileClause.java
@@ -27,7 +27,6 @@ import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
-import org.apache.doris.common.FeNameFormat;
import org.apache.doris.common.Pair;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.ParseUtil;
@@ -588,7 +587,6 @@ public class OutFileClause {
if (properties.containsKey(PROP_SUCCESS_FILE_NAME)) {
successFileName = properties.get(PROP_SUCCESS_FILE_NAME);
- FeNameFormat.checkCommonName("file name", successFileName);
processedPropKeys.add(PROP_SUCCESS_FILE_NAME);
}
diff --git
a/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
b/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
deleted file mode 100644
index 57a71aceb9..0000000000
---
a/regression-test/data/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.out
+++ /dev/null
@@ -1,447 +0,0 @@
--- This file is automatically generated. You should know what you did if you
want to edit this
--- !sql --
-0
-
--- !sql --
-1
-
--- !sql --
-1
-
--- !sql --
-1,2
-
--- !sql --
-
-
--- !sql --
-\N
-
--- !sql --
-false
-
--- !sql --
-true
-
--- !sql --
-0
-
--- !sql --
-
-
--- !sql --
-0,1,2
-
--- !sql --
-\N
-
--- !sql --
-false
-
--- !sql --
-true
-
--- !sql --
-true
-
--- !sql --
-false
-
--- !sql_bitmap_hash1 --
-1
-
--- !sql_bitmap_hash2 --
-1
-
--- !sql_bitmap_hash3 --
-0
-
--- !sql_bitmap_hash64_1 --
-1
-
--- !sql_bitmap_hash64_2 --
-1
-
--- !sql_bitmap_hash64_3 --
-0
-
--- !sql_bitmap_or1 --
-2
-
--- !sql_bitmap_or2 --
-1
-
--- !sql_bitmap_or3 --
-1,2
-
--- !sql_bitmap_or4 --
-0,1,2,10
-
--- !sql_bitmap_or5 --
-0,1,2,10
-
--- !sql_bitmap_or6 --
-1,2,3,4,5,10
-
--- !sql_bitmap_or7 --
-1
-
--- !sql_bitmap_or8 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_or_count6 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_or9 --
-1 2
-2 2
-
--- !sql_bitmap_or_count7 --
-1 2
-2 2
-
--- !sql_bitmap_or10 --
-1 11,111
-2 22,222
-3 33
-4 44
-
--- !sql_bitmap_or11 --
-1 11,111
-2 22,222
-
--- !sql_bitmap_or12 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_or_count8 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_or13 --
-1 2
-2 2
-
--- !sql_bitmap_or_count9 --
-1 2
-2 2
-
--- !sql_bitmap_or14 --
-1 11,111
-2 22,222
-3 33
-4 44
-
--- !sql_bitmap_or15 --
-1 11,111
-2 22,222
-
--- !sql_bitmap_or16_0 --
-false
-
--- !sql_bitmap_or16_1 --
-true
-
--- !sql_bitmap_or16 --
-true
-
--- !sql_bitmap_or17 --
-0
-
--- !sql_bitmap_or_count10 --
-0
-
--- !sql_bitmap_or18 --
-\N
-
--- !sql_bitmap_or19 --
-true
-
--- !sql_bitmap_or21 --
-\N
-
--- !sql_bitmap_or22_0 --
-3 1 0
-4 1 0
-
--- !sql_bitmap_or22_1 --
-5 0 1
-
--- !sql_bitmap_or22 --
-3 \N \N 5 true
-4 \N \N 5 true
-
--- !sql_bitmap_or_count11 --
-3 \N \N 5 0
-4 \N \N 5 0
-
--- !sql_bitmap_or23 --
-3 \N \N 5 \N
-4 \N \N 5 \N
-
--- !sql_bitmap_and_count1 --
-0
-
--- !sql_bitmap_and_count2 --
-3
-
--- !sql_bitmap_and_count3 --
-1
-
--- !sql_bitmap_and_count4 --
-2
-
--- !sql_bitmap_and_count5 --
-0
-
--- !sql_bitmap_and_count6 --
-0
-
--- !sql_bitmap_or_count1 --
-3
-
--- !sql_bitmap_or_count2 --
-3
-
--- !sql_bitmap_or_count3 --
-5
-
--- !sql_bitmap_or_count4 --
-6
-
--- !sql_bitmap_or_count5 --
-6
-
--- !sql --
-2
-
--- !sql --
-1,4
-
--- !sql --
-1,3,5
-
--- !sql --
-1,3,5
-
--- !sql --
-\N
-
--- !sql_bitmap_xor_count1 --
-4
-
--- !sql_bitmap_xor_count2 --
-0
-
--- !sql_bitmap_xor_count3 --
-6
-
--- !sql_bitmap_xor_count4 --
-3
-
--- !sql_bitmap_xor_count5 --
-3
-
--- !sql_bitmap_xor_count6 --
-0
-
--- !sql_bitmap_and_count7 --
-1 1
-2 1
-3 0
-4 0
-
--- !sql_bitmap_xor_count7 --
-1 2
-2 2
-3 0
-4 0
-
--- !sql_bitmap_and_not_count3 --
-1 1
-2 1
-3 0
-4 0
-
--- !sql_bitmap_and_count8 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_xor_count8 --
-1 3
-2 3
-3 1
-4 1
-
--- !sql_bitmap_and_not_count4 --
-1 2
-2 2
-3 1
-4 1
-
--- !sql_bitmap_and_count9 --
-1 1
-2 1
-
--- !sql_bitmap_xor_count9 --
-1 2
-2 2
-
--- !sql_bitmap_and_not_count5 --
-1 1
-2 1
-
--- !sql_bitmap_and_count10 --
-1 1
-2 3
-
--- !sql_bitmap_xor_count10 --
-1 2
-2 1
-
--- !sql_bitmap_and_not_count6 --
-1 1
-2 1
-
--- !sql_bitmap_and_count11 --
-1 2
-2 4
-
--- !sql_bitmap_xor_count11 --
-1 3
-2 2
-
--- !sql_bitmap_and_not_count7 --
-1 2
-2 2
-
--- !sql --
-0
-
--- !sql --
-5
-
--- !sql --
-2
-
--- !sql_bitmap_and_not_count1 --
-2
-
--- !sql_bitmap_and_not_count2 --
-0
-
--- !sql --
-1,2,3,4,5
-
--- !sql --
-2
-
--- !sql --
-1,2,3
-
--- !sql --
-4,5
-
--- !sql --
-0,1,2
-
--- !sql --
-2,3
-
--- !sql --
-2,3,5
-
--- !sql --
-\N
-
--- !sql --
-
-
--- !sql --
-1
-
--- !sql --
-1,2
-
--- !sql --
-1 \N
-2 \N
-
--- !sql --
-1 3
-2 2
-
--- !sql --
-1 3
-2 2
-
--- !sql --
-2
-
--- !sql --
-1,4
-
--- !sql --
-1,3,5
-
--- !sql --
-1,3,5
-
--- !sql --
-\N
-
--- !sql --
-1
-
--- !sql --
-
-
--- !sql --
-\N
-
--- !sql --
-9999999999
-
--- !sql --
-4 1,2,3
-3 1,2,3,4,5
-
--- !sql --
-3
-
--- !sql --
-\N
-
--- !sql --
-0
-
--- !sql --
-0
-
--- !sql --
-1,2,3
-
--- !sql --
-1
-
--- !sql --
-100
-
--- !sql --
-20221103
-
--- !sql --
-\N
-
diff --git a/regression-test/data/query_p0/group_concat/test_group_concat.out
b/regression-test/data/query_p0/group_concat/test_group_concat.out
index 8caca13a7e..e61bd4fd4f 100644
--- a/regression-test/data/query_p0/group_concat/test_group_concat.out
+++ b/regression-test/data/query_p0/group_concat/test_group_concat.out
@@ -25,4 +25,3 @@ false
25699 1989
2147483647 255:1991:32767:32767
-
diff --git a/regression-test/suites/export/test_array_export.groovy
b/regression-test/suites/export/test_array_export.groovy
index 0484bc4499..3d7281742a 100644
--- a/regression-test/suites/export/test_array_export.groovy
+++ b/regression-test/suites/export/test_array_export.groovy
@@ -27,6 +27,15 @@ suite("test_array_export", "export") {
strBuilder.append("curl --location-trusted -u " + context.config.jdbcUser
+ ":" + context.config.jdbcPassword)
strBuilder.append(" http://" + context.config.feHttpAddress +
"/rest/v1/config/fe")
+ def get_outfile_path = { prefix, suffix ->
+ def file_prefix = prefix;
+ def index = file_prefix.indexOf("/tmp/");
+ file_prefix = file_prefix.substring(index);
+ def file_path = file_prefix + "0." + suffix;
+ logger.info("output file: " + file_path);
+ return file_path;
+ }
+
String command = strBuilder.toString()
def process = command.toString().execute()
def code = process.waitFor()
diff --git a/regression-test/suites/export_p0/test_outfile.groovy
b/regression-test/suites/export_p0/test_outfile.groovy
index d2ceb46c5e..2a770ca027 100644
--- a/regression-test/suites/export_p0/test_outfile.groovy
+++ b/regression-test/suites/export_p0/test_outfile.groovy
@@ -26,6 +26,15 @@ suite("test_outfile") {
strBuilder.append("curl --location-trusted -u " + context.config.jdbcUser
+ ":" + context.config.jdbcPassword)
strBuilder.append(" http://" + context.config.feHttpAddress +
"/rest/v1/config/fe")
+ def get_outfile_path = { prefix, suffix ->
+ def file_prefix = prefix;
+ def index = file_prefix.indexOf("/tmp/");
+ file_prefix = file_prefix.substring(index);
+ def file_path = file_prefix + "0." + suffix;
+ logger.info("output file: " + file_path);
+ return file_path;
+ }
+
String command = strBuilder.toString()
def process = command.toString().execute()
def code = process.waitFor()
@@ -49,8 +58,7 @@ suite("test_outfile") {
return
}
def tableName = "outfile_test"
- def uuid = UUID.randomUUID().toString()
- def outFilePath = """/tmp/test_outfile_${uuid}"""
+ def outFilePath = """/tmp/"""
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
@@ -91,19 +99,16 @@ suite("test_outfile") {
"""
qt_select_default """ SELECT * FROM ${tableName} t ORDER BY user_id;
"""
- // check outfile
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
- sql """
+ def result = sql """
SELECT * FROM ${tableName} t ORDER BY user_id INTO OUTFILE
"file://${outFilePath}/";
"""
- File[] files = path.listFiles()
- assert files.length == 1
- List<String> outLines =
Files.readAllLines(Paths.get(files[0].getAbsolutePath()),
StandardCharsets.UTF_8);
+ assertTrue(result.size() == 1)
+ assertTrue(result[0][0] == 1)
+ def file_path = get_outfile_path(result[0][3], "csv");
+ def path = new File(file_path)
+ assert path.exists()
+
+ List<String> outLines =
Files.readAllLines(Paths.get(path.getAbsolutePath()), StandardCharsets.UTF_8);
List<String> baseLines =
Files.readAllLines(Paths.get("""${context.config.dataPath}/export_p0/test_outfile.out"""),
StandardCharsets.UTF_8)
for (int j = 0; j < outLines.size(); j ++) {
String[] outLine = outLines.get(j).split("\t")
@@ -123,17 +128,10 @@ suite("test_outfile") {
}
}
} finally {
- try_sql("DROP TABLE IF EXISTS ${tableName}")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
}
// test hll column outfile
+ def uuid = UUID.randomUUID().toString()
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
@@ -155,46 +153,28 @@ suite("test_outfile") {
(706432 , hll_hash(706432 ), 1), (706432 , hll_hash(706432 ), 1)
"""
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
-
sql "set return_object_data_as_binary = false"
- sql """
- SELECT * FROM ${tableName} t ORDER BY k1, v2 INTO OUTFILE
"file://${outFilePath}/" properties("success_file_name" = "SUCCESS")
+ def result = sql """
+ SELECT * FROM ${tableName} t ORDER BY k1, v2 INTO OUTFILE
"file://${outFilePath}/" properties("success_file_name" = "SUCCESS_${uuid}")
"""
+ assertTrue(result.size() == 1)
+ assertTrue(result[0][0] == 1)
+ def file_path = get_outfile_path(result[0][3], "csv");
+ def path = new File(file_path)
+ assert path.exists()
- File[] files = path.listFiles()
- assert files.length == 2 // one is outfile, the other is SUCCESS file
- File dataFile = files[0].getName().contains("SUCCESS") ? files[1] :
files[0];
- List<String> outLines =
Files.readAllLines(Paths.get(dataFile.getAbsolutePath()),
StandardCharsets.UTF_8);
+ List<String> outLines =
Files.readAllLines(Paths.get(path.getAbsolutePath()), StandardCharsets.UTF_8);
assertEquals(2, outLines.size())
String[] outLine1 = outLines.get(0).split("\t")
assertEquals(3, outLine1.size())
assert outLine1[1] == "\\N"
assert outLines.get(1).split("\t")[1] == "\\N"
} finally {
- try_sql("DROP TABLE IF EXISTS ${tableName}")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
}
// test parallel output
+ uuid = UUID.randomUUID().toString()
try {
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
sql """drop table if exists select_into_file"""
sql """CREATE TABLE `select_into_file` (
`id` int,
@@ -209,15 +189,7 @@ suite("test_outfile") {
(4, "c"), (5, "睿"), (6, "多"), (7, "丝"), (8, "test"),
(100, "aa"), (111, "bb"), (123, "cc"), (222, "dd");"""
sql "set enable_parallel_outfile = true;"
- sql """select * from select_into_file into outfile
"file://${outFilePath}/" properties("success_file_name" = "SUCCESS");"""
+ sql """select * from select_into_file into outfile
"file://${outFilePath}/" properties("success_file_name" = "SUCCESS_${uuid}");"""
} finally {
- try_sql("DROP TABLE IF EXISTS select_into_file")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
}
}
diff --git a/regression-test/suites/export_p0/test_outfile_expr.groovy
b/regression-test/suites/export_p0/test_outfile_expr.groovy
index 6649123958..c638216773 100644
--- a/regression-test/suites/export_p0/test_outfile_expr.groovy
+++ b/regression-test/suites/export_p0/test_outfile_expr.groovy
@@ -26,6 +26,15 @@ suite("test_outfile_expr") {
strBuilder.append("curl --location-trusted -u " + context.config.jdbcUser
+ ":" + context.config.jdbcPassword)
strBuilder.append(" http://" + context.config.feHttpAddress +
"/rest/v1/config/fe")
+ def get_outfile_path = { prefix, suffix ->
+ def file_prefix = prefix;
+ def index = file_prefix.indexOf("/tmp/");
+ file_prefix = file_prefix.substring(index);
+ def file_path = file_prefix + "0." + suffix;
+ logger.info("output file: " + file_path);
+ return file_path;
+ }
+
String command = strBuilder.toString()
def process = command.toString().execute()
def code = process.waitFor()
@@ -49,8 +58,7 @@ suite("test_outfile_expr") {
return
}
def tableName = "outfile_test_expr"
- def uuid = UUID.randomUUID().toString()
- def outFilePath = """/tmp/test_outfile_expr_${uuid}"""
+ def outFilePath = """/tmp/"""
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
@@ -87,19 +95,16 @@ suite("test_outfile_expr") {
"""
qt_select_default """ SELECT user_id+1, age+sex, repeat(char_col, 10)
FROM ${tableName} t ORDER BY user_id; """
- // check outfile
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
- sql """
+ def result = sql """
SELECT user_id+1, age+sex, repeat(char_col, 10) FROM ${tableName}
t ORDER BY user_id INTO OUTFILE "file://${outFilePath}/";
"""
- File[] files = path.listFiles()
- assert files.length == 1
- List<String> outLines =
Files.readAllLines(Paths.get(files[0].getAbsolutePath()),
StandardCharsets.UTF_8);
+ assertTrue(result.size() == 1)
+ assertTrue(result[0][0] == 1)
+ def file_path = get_outfile_path(result[0][3], "csv");
+ def path = new File(file_path)
+ assert path.exists()
+
+ List<String> outLines =
Files.readAllLines(Paths.get(path.getAbsolutePath()), StandardCharsets.UTF_8);
List<String> baseLines =
Files.readAllLines(Paths.get("""${context.config.dataPath}/export_p0/test_outfile_expr.out"""),
StandardCharsets.UTF_8)
for (int j = 0; j < outLines.size(); j ++) {
String[] outLine = outLines.get(j).split("\t")
@@ -119,14 +124,6 @@ suite("test_outfile_expr") {
}
}
} finally {
- try_sql("DROP TABLE IF EXISTS ${tableName}")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
}
}
diff --git a/regression-test/suites/export_p0/test_outfile_parquet.groovy
b/regression-test/suites/export_p0/test_outfile_parquet.groovy
index 9be0c8fdc4..babe50690f 100644
--- a/regression-test/suites/export_p0/test_outfile_parquet.groovy
+++ b/regression-test/suites/export_p0/test_outfile_parquet.groovy
@@ -29,6 +29,15 @@ suite("test_outfile_parquet") {
strBuilder.append("curl --location-trusted -u " + context.config.jdbcUser
+ ":" + context.config.jdbcPassword)
strBuilder.append(" http://" + context.config.feHttpAddress +
"/rest/v1/config/fe")
+ def get_outfile_path = { prefix, suffix ->
+ def file_prefix = prefix;
+ def index = file_prefix.indexOf("/tmp/");
+ file_prefix = file_prefix.substring(index);
+ def file_path = file_prefix + "0." + suffix;
+ logger.info("output file: " + file_path);
+ return file_path;
+ }
+
String command = strBuilder.toString()
def process = command.toString().execute()
def code = process.waitFor()
@@ -53,8 +62,7 @@ suite("test_outfile_parquet") {
}
def tableName = "outfile_parquet_test"
def tableName2 = "outfile_parquet_test2"
- def uuid = UUID.randomUUID().toString()
- def outFilePath = """/tmp/test_outfile_parquet_${uuid}"""
+ def outFilePath = """/tmp/"""
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
@@ -95,19 +103,14 @@ suite("test_outfile_parquet") {
"""
qt_select_default """ SELECT * FROM ${tableName} t ORDER BY user_id;
"""
- // check outfile
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
- sql """
+ def result = sql """
SELECT * FROM ${tableName} t ORDER BY user_id INTO OUTFILE
"file://${outFilePath}/" FORMAT AS PARQUET;
"""
-
- File[] files = path.listFiles()
- assert files.length == 1
+ assertTrue(result.size() == 1)
+ assertTrue(result[0][0] == 1)
+ def file_path = get_outfile_path(result[0][3], "parquet");
+ def path = new File(file_path)
+ assert path.exists()
sql """ DROP TABLE IF EXISTS ${tableName2} """
sql """
@@ -136,7 +139,7 @@ suite("test_outfile_parquet") {
StringBuilder commandBuilder = new StringBuilder()
commandBuilder.append("""curl -v --location-trusted -u
${context.config.feHttpUser}:${context.config.feHttpPassword}""")
- commandBuilder.append(""" -H format:parquet -T """ +
files[0].getAbsolutePath() + """ http://${context.config.feHttpAddress}/api/"""
+ dbName + "/" + tableName2 + "/_stream_load")
+ commandBuilder.append(""" -H format:parquet -T """ +
path.getAbsolutePath() + """ http://${context.config.feHttpAddress}/api/""" +
dbName + "/" + tableName2 + "/_stream_load")
command = commandBuilder.toString()
process = command.execute()
code = process.waitFor()
@@ -146,14 +149,5 @@ suite("test_outfile_parquet") {
assertEquals(code, 0)
qt_select_default """ SELECT * FROM ${tableName2} t ORDER BY user_id;
"""
} finally {
- try_sql("DROP TABLE IF EXISTS ${tableName}")
- try_sql("DROP TABLE IF EXISTS ${tableName2}")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
}
}
diff --git a/regression-test/suites/export_p0/test_outfile_separator.groovy
b/regression-test/suites/export_p0/test_outfile_separator.groovy
index 4d11af6b09..a1980f6c15 100644
--- a/regression-test/suites/export_p0/test_outfile_separator.groovy
+++ b/regression-test/suites/export_p0/test_outfile_separator.groovy
@@ -22,6 +22,17 @@ import java.nio.file.Files
import java.nio.file.Paths
suite("test_outfile_separator") {
+
+ def get_outfile_path = { prefix, suffix ->
+ def file_prefix = prefix;
+ def index = file_prefix.indexOf("/tmp/");
+ file_prefix = file_prefix.substring(index);
+ def file_path = file_prefix + "0." + suffix;
+ logger.info("output file: " + file_path);
+ return file_path;
+ }
+
+
StringBuilder strBuilder = new StringBuilder()
strBuilder.append("curl --location-trusted -u " + context.config.jdbcUser
+ ":" + context.config.jdbcPassword)
strBuilder.append(" http://" + context.config.feHttpAddress +
"/rest/v1/config/fe")
@@ -50,8 +61,7 @@ suite("test_outfile_separator") {
}
def dbName = context.config.getDbNameByFile(context.file)
def tableName = "outfile_test_separator"
- def uuid = UUID.randomUUID().toString()
- def outFilePath = """/tmp/test_outfile_separator_${uuid}"""
+ def outFilePath = """/tmp/"""
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
@@ -65,40 +75,30 @@ suite("test_outfile_separator") {
"""
qt_select_1 """ SELECT * FROM ${tableName} t ORDER BY k1; """
- // check outfile
- File path = new File(outFilePath)
- if (!path.exists()) {
- assert path.mkdirs()
- } else {
- throw new IllegalStateException("""${outFilePath} already exists!
""")
- }
- sql """
+ def result = sql """
SELECT * FROM ${tableName} t INTO OUTFILE "file://${outFilePath}/"
properties("column_separator" = "\\\\x01");
"""
- File[] files = path.listFiles()
- assert files.length == 1
- List<String> outLines =
Files.readAllLines(Paths.get(files[0].getAbsolutePath()),
StandardCharsets.UTF_8);
+ assertTrue(result.size() == 1)
+ assertTrue(result[0][0] == 1)
+ def file_path = get_outfile_path(result[0][3], "csv");
+ def path = new File(file_path)
+ assert path.exists()
+
+ List<String> outLines =
Files.readAllLines(Paths.get(path.getAbsolutePath()), StandardCharsets.UTF_8);
assert outLines.size() == 2
streamLoad {
db """${dbName}"""
table 'outfile_test_separator'
set 'column_separator', '\\x01'
- file files[0].getAbsolutePath()
+ file path.getAbsolutePath()
time 10000 // limit inflight 10s
}
qt_select_2 """ SELECT * FROM ${tableName} t ORDER BY k1; """
} finally {
- try_sql("DROP TABLE IF EXISTS ${tableName}")
- File path = new File(outFilePath)
- if (path.exists()) {
- for (File f: path.listFiles()) {
- f.delete();
- }
- path.delete();
- }
+ // try_sql("DROP TABLE IF EXISTS ${tableName}")
}
}
diff --git
a/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
b/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
deleted file mode 100644
index 4f8d6416dd..0000000000
---
a/regression-test/suites/nereids_p0/sql_functions/bitmap_functions/test_bitmap_function.groovy
+++ /dev/null
@@ -1,640 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License 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.
-
-suite("test_bitmap_function") {
- sql "SET enable_nereids_planner=true"
- sql "SET enable_fallback_to_original_planner=false"
- // BITMAP_AND
- qt_sql """ select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(2))) cnt
"""
- qt_sql """ select bitmap_count(bitmap_and(to_bitmap(1), to_bitmap(1))) cnt
"""
- qt_sql """ select bitmap_to_string(bitmap_and(to_bitmap(1), to_bitmap(1)))
"""
- qt_sql """ select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'),
bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) """
- qt_sql """ select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'),
bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),bitmap_empty())) """
- qt_sql """ select bitmap_to_string(bitmap_and(bitmap_from_string('1,2,3'),
bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'),NULL)) """
-
- // BITMAP_CONTAINS
- qt_sql """ select bitmap_contains(to_bitmap(1),2) cnt """
- qt_sql """ select bitmap_contains(to_bitmap(1),1) cnt """
-
- // BITMAP_EMPTY
- qt_sql """ select bitmap_count(bitmap_empty()) """
-
- // BITMAP_FROM_STRING
- qt_sql """ select bitmap_to_string(bitmap_empty()) """
- qt_sql """ select bitmap_to_string(bitmap_from_string("0, 1, 2")) """
- qt_sql """ select bitmap_from_string("-1, 0, 1, 2") """
-
- // BITMAP_HAS_ANY
- qt_sql """ select bitmap_has_any(to_bitmap(1),to_bitmap(2)) cnt """
- qt_sql """ select bitmap_has_any(to_bitmap(1),to_bitmap(1)) cnt """
-
- // BITMAP_HAS_ALL
- qt_sql """ select bitmap_has_all(bitmap_from_string("0, 1, 2"),
bitmap_from_string("1, 2")) cnt """
- qt_sql """ select bitmap_has_all(bitmap_empty(), bitmap_from_string("1,
2")) cnt """
-
- // BITMAP_HASH
- qt_sql_bitmap_hash1 """ select bitmap_count(bitmap_hash('hello')) """
- qt_sql_bitmap_hash2 """ select bitmap_count(bitmap_hash('')) """
- qt_sql_bitmap_hash3 """ select bitmap_count(bitmap_hash(null)) """
-
- // BITMAP_HASH64
- qt_sql_bitmap_hash64_1 """ select bitmap_count(bitmap_hash64('hello')) """
- qt_sql_bitmap_hash64_2 """ select bitmap_count(bitmap_hash64('')) """
- qt_sql_bitmap_hash64_3 """ select bitmap_count(bitmap_hash64(null)) """
-
- // BITMAP_OR
- qt_sql_bitmap_or1 """ select bitmap_count(bitmap_or(to_bitmap(1),
to_bitmap(2))) cnt """
- qt_sql_bitmap_or2 """ select bitmap_count(bitmap_or(to_bitmap(1),
to_bitmap(1))) cnt """
- qt_sql_bitmap_or3 """ select bitmap_to_string(bitmap_or(to_bitmap(1),
to_bitmap(2))) """
- // TODO: fix constant fold of bitmap_or and enable this case
- // qt_sql_bitmap_or4 """ select bitmap_to_string(bitmap_or(to_bitmap(1),
to_bitmap(2), to_bitmap(10), to_bitmap(0), NULL)) """
- qt_sql_bitmap_or5 """ select bitmap_to_string(bitmap_or(to_bitmap(1),
to_bitmap(2), to_bitmap(10), to_bitmap(0), bitmap_empty())) """
- qt_sql_bitmap_or6 """ select bitmap_to_string(bitmap_or(to_bitmap(10),
bitmap_from_string('1,2'), bitmap_from_string('1,2,3,4,5'))) """
- // TODO: fix constant fold of bitmap_or and enable this case
- // qt_sql_bitmap_or7 """ select bitmap_count(bitmap_or(to_bitmap(1),
null)) cnt """
-
- // bitmap_or of all nullable column
- sql """ DROP TABLE IF EXISTS test_bitmap1 """
- sql """ DROP TABLE IF EXISTS test_bitmap2 """
- sql """
- CREATE TABLE test_bitmap1 (
- dt INT(11) NULL,
- id bitmap BITMAP_UNION NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap1
- values
- (1, to_bitmap(11)),
- (2, to_bitmap(22)),
- (3, to_bitmap(33)),
- (4, to_bitmap(44));
- """
- sql """
- CREATE TABLE test_bitmap2 (
- dt INT(11) NULL,
- id bitmap BITMAP_UNION NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap2
- values
- (1, to_bitmap(111)),
- (2, to_bitmap(222)),
- (5, to_bitmap(555));
- """
- qt_sql_bitmap_or8 """
- select
- l.dt,
- bitmap_count(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_or_count6 """
- select
- l.dt,
- bitmap_or_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_or9 """
- select
- l.dt,
- bitmap_count(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_or_count7 """
- select
- l.dt,
- bitmap_or_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_or10 """
- select
- l.dt,
- bitmap_to_string(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt
- """
- qt_sql_bitmap_or11 """
- select
- l.dt,
- bitmap_to_string(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt
- """
-
- // bitmap_or of NOT NULLABLE column and nullable column
- sql """ DROP TABLE IF EXISTS test_bitmap1 """
- sql """
- CREATE TABLE test_bitmap1 (
- dt INT(11) NULL,
- id bitmap BITMAP_UNION NOT NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap1
- values
- (1, to_bitmap(11)),
- (2, to_bitmap(22)),
- (3, to_bitmap(33)),
- (4, to_bitmap(44));
- """
- qt_sql_bitmap_or12 """
- select
- l.dt,
- bitmap_count(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_or_count8 """
- select
- l.dt,
- bitmap_or_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_or13 """
- select
- l.dt,
- bitmap_count(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_or_count9 """
- select
- l.dt,
- bitmap_or_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_or14 """
- select
- l.dt,
- bitmap_to_string(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt
- """
- qt_sql_bitmap_or15 """
- select
- l.dt,
- bitmap_to_string(bitmap_or(l.id, r.id)) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt
- """
-
- qt_sql_bitmap_or16_0 """ select bitmap_from_string("1") is null """
- qt_sql_bitmap_or16_1 """ select bitmap_from_string("a") is null """
- qt_sql_bitmap_or16 """ select bitmap_or(bitmap_from_string("a"),
bitmap_from_string("b")) is null"""
- qt_sql_bitmap_or17 """ select
bitmap_count(bitmap_or(bitmap_from_string("a"), bitmap_from_string("b"))) """
- qt_sql_bitmap_or_count10 """ select
bitmap_or_count(bitmap_from_string("a"), bitmap_from_string("b")) """
- qt_sql_bitmap_or18 """ select
bitmap_to_string(bitmap_or(bitmap_from_string("a"), bitmap_from_string("b")))
"""
- qt_sql_bitmap_or19 """ select bitmap_or(null, null) is null"""
- // qt_sql_bitmap_or20 """ select bitmap_count(bitmap_or(null, null))"""
- qt_sql_bitmap_or21 """ select bitmap_to_string(bitmap_or(null, null))"""
-
- sql """ drop view if exists v1 """
- sql """ drop view if exists v2 """
- sql """
- create view v1 as
- (select
- l.dt ldt,
- l.id lid,
- r.dt rdt,
- r.id rid
- from
- test_bitmap1 l
- left join test_bitmap2 r on l.dt = r.dt
- where r.id is null);
- """
- sql """
- create view v2 as
- (select
- l.dt ldt,
- l.id lid,
- r.dt rdt,
- r.id rid
- from
- test_bitmap1 l
- right join test_bitmap2 r on l.dt = r.dt
- where l.id is null);
- """
-
- // test bitmap_or of all non-const null column values
- qt_sql_bitmap_or22_0 """ select ldt, bitmap_count(lid), bitmap_count(rid)
from v1 where rid is null order by ldt; """
- qt_sql_bitmap_or22_1 """ select rdt, bitmap_count(lid), bitmap_count(rid)
from v2 where lid is null order by rdt; """
- qt_sql_bitmap_or22 """ select v1.ldt, v1.rdt, v2.ldt, v2.rdt,
bitmap_or(v1.rid, v2.lid) is null from v1, v2 order by v1.ldt, v2.rdt; """
- qt_sql_bitmap_or_count11 """ select v1.ldt, v1.rdt, v2.ldt, v2.rdt,
bitmap_or_count(v1.rid, v2.lid) from v1, v2 order by v1.ldt, v2.rdt; """
- qt_sql_bitmap_or23 """ select v1.ldt, v1.rdt, v2.ldt, v2.rdt,
bitmap_to_string(bitmap_or(v1.rid, v2.lid)) from v1, v2 order by v1.ldt,
v2.rdt; """
-
- // bitmap_and_count
- qt_sql_bitmap_and_count1 """ select
bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_empty()) """
- qt_sql_bitmap_and_count2 """ select
bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')) """
- qt_sql_bitmap_and_count3 """ select
bitmap_and_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) """
- qt_sql_bitmap_and_count4 """ select
bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'),
bitmap_from_string('1,2,3,4,5')) """
- qt_sql_bitmap_and_count5 """ select
bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'),
bitmap_from_string('1,2,3,4,5'),bitmap_empty()) """
- // TODO: fix constant fold and enable this case
- // qt_sql_bitmap_and_count6 """ select
bitmap_and_count(bitmap_from_string('1,2,3'), bitmap_from_string('1,2'),
bitmap_from_string('1,2,3,4,5'), NULL) """
-
- // bitmap_or_count
- qt_sql_bitmap_or_count1 """ select
bitmap_or_count(bitmap_from_string('1,2,3'),bitmap_empty()) """
- qt_sql_bitmap_or_count2 """ select
bitmap_or_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3'))"""
- qt_sql_bitmap_or_count3 """ select
bitmap_or_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) """
- qt_sql_bitmap_or_count4 """ select
bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'),
to_bitmap(100), bitmap_empty()) """
- // TODO: fix constant fold of bitmap_or and enable this case
- // qt_sql_bitmap_or_count5 """ select
bitmap_or_count(bitmap_from_string('1,2,3'), bitmap_from_string('3,4,5'),
to_bitmap(100), NULL) """
-
- // BITMAP_XOR
- qt_sql """ select
bitmap_count(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')))
cnt """
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')))
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')))
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()))
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL))
"""
-
- // BITMAP_XOR_COUNT
- qt_sql_bitmap_xor_count1 """ select
bitmap_xor_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')) """
- qt_sql_bitmap_xor_count2 """ select
bitmap_xor_count(bitmap_from_string('1,2,3'),bitmap_from_string('1,2,3')) """
- qt_sql_bitmap_xor_count3 """ select
bitmap_xor_count(bitmap_from_string('1,2,3'),bitmap_from_string('4,5,6')) """
- qt_sql_bitmap_xor_count4 """ select
(bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')))
"""
- qt_sql_bitmap_xor_count5 """ select
(bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()))
"""
- // TODO: fix constant fold and enable this case
- // qt_sql_bitmap_xor_count6 """ select
(bitmap_xor_count(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL))
"""
-
- // bitmap_and_count, bitmap_xor_count, bitmap_and_not_count of all
nullable column
- sql """ DROP TABLE IF EXISTS test_bitmap1 """
- sql """ DROP TABLE IF EXISTS test_bitmap2 """
- sql """
- CREATE TABLE test_bitmap1 (
- dt INT(11) NULL,
- id bitmap BITMAP_UNION NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap1
- values
- (1, bitmap_from_string("11,111")),
- (2, bitmap_from_string("22,222")),
- (3, bitmap_from_string("33,333")),
- (4, bitmap_from_string("44,444"));
- """
- sql """
- CREATE TABLE test_bitmap2 (
- dt INT(11) NULL,
- id bitmap BITMAP_UNION NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap2
- values
- (1, bitmap_from_string("11,1111")),
- (2, bitmap_from_string("22,2222")),
- (5, bitmap_from_string("55,5555"));
- """
- qt_sql_bitmap_and_count7 """
- select
- l.dt,
- bitmap_and_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_xor_count7 """
- select
- l.dt,
- bitmap_xor_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_and_not_count3 """
- select
- l.dt,
- bitmap_and_not_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_and_count8 """
- select
- l.dt,
- bitmap_and_count(l.id, r.id) + 1 count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_xor_count8 """
- select
- l.dt,
- bitmap_xor_count(l.id, r.id) + 1 count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_and_not_count4 """
- select
- l.dt,
- bitmap_and_not_count(l.id, r.id) + 1 count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- order by l.dt, count
- """
- qt_sql_bitmap_and_count9 """
- select
- l.dt,
- bitmap_and_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_xor_count9 """
- select
- l.dt,
- bitmap_xor_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- qt_sql_bitmap_and_not_count5 """
- select
- l.dt,
- bitmap_and_not_count(l.id, r.id) count
- from
- test_bitmap1 l left join test_bitmap2 r
- on l.dt = r.dt
- where r.id is not null
- order by l.dt, count
- """
- // bitmap_and_count, bitmap_xor_count, bitmap_and_not_count of all not
nullable column
- sql """ DROP TABLE IF EXISTS test_bitmap1 """
- sql """
- CREATE TABLE test_bitmap1 (
- dt INT(11) NOT NULL,
- id1 bitmap BITMAP_UNION NOT NULL,
- id2 bitmap BITMAP_UNION NOT NULL
- ) ENGINE=OLAP
- AGGREGATE KEY(dt)
- DISTRIBUTED BY HASH(dt) BUCKETS 2
- properties (
- "replication_num" = "1"
- );
- """
- sql """
- insert into
- test_bitmap1
- values
- (1, bitmap_from_string("11,1111"), bitmap_from_string("11,111")),
- (2, bitmap_from_string("22,222,2222,22222"),
bitmap_from_string("22,222,2222"))
- """
- qt_sql_bitmap_and_count10 """
- select
- dt,
- bitmap_and_count(id1, id2) count
- from
- test_bitmap1
- order by dt, count
- """
- qt_sql_bitmap_xor_count10 """
- select
- dt,
- bitmap_xor_count(id1, id2) count
- from
- test_bitmap1
- order by dt, count
- """
- qt_sql_bitmap_and_not_count6 """
- select
- dt,
- bitmap_and_not_count(id1, id2) count
- from
- test_bitmap1
- order by dt, count
- """
- qt_sql_bitmap_and_count11 """
- select
- dt,
- bitmap_and_count(id1, id2) + 1 count
- from
- test_bitmap1
- order by dt, count
- """
- qt_sql_bitmap_xor_count11 """
- select
- dt,
- bitmap_xor_count(id1, id2) + 1 count
- from
- test_bitmap1
- order by dt, count
- """
- qt_sql_bitmap_and_not_count7 """
- select
- dt,
- bitmap_and_not_count(id1, id2) + 1 count
- from
- test_bitmap1
- order by dt, count
- """
-
- // BITMAP_NOT
- qt_sql """ select
bitmap_count(bitmap_not(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')))
cnt """
- qt_sql """ select
bitmap_to_string(bitmap_not(bitmap_from_string('2,3,5'),bitmap_from_string('1,2,3,4')))
"""
-
- // BITMAP_AND_NOT
- qt_sql """ select
bitmap_count(bitmap_and_not(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5')))
cnt """
-
- // BITMAP_AND_NOT_COUNT
- qt_sql_bitmap_and_not_count1 """ select
bitmap_and_not_count(bitmap_from_string('1,2,3'),bitmap_from_string('3,4,5'))
cnt """
- // TODO: fix constant fold and enable this case
- // qt_sql_bitmap_and_not_count2 """ select
bitmap_and_not_count(bitmap_from_string('1,2,3'),null) cnt """
-
- // BITMAP_SUBSET_IN_RANGE
- qt_sql """ select
bitmap_to_string(bitmap_subset_in_range(bitmap_from_string('1,2,3,4,5'), 0, 9))
value """
- qt_sql """ select
bitmap_to_string(bitmap_subset_in_range(bitmap_from_string('1,2,3,4,5'), 2, 3))
value """
-
- // BITMAP_SUBSET_LIMIT
- qt_sql """ select
bitmap_to_string(bitmap_subset_limit(bitmap_from_string('1,2,3,4,5'), 0, 3))
value """
- qt_sql """ select
bitmap_to_string(bitmap_subset_limit(bitmap_from_string('1,2,3,4,5'), 4, 3))
value """
-
- // SUB_BITMAP
- qt_sql """ select
bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), 0, 3)) value
"""
- qt_sql """ select
bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), -3, 2)) value
"""
- qt_sql """ select
bitmap_to_string(sub_bitmap(bitmap_from_string('1,0,1,2,3,1,5'), 2, 100)) value
"""
-
- // BITMAP_TO_STRING
- qt_sql """ select bitmap_to_string(null) """
- qt_sql """ select bitmap_to_string(bitmap_empty()) """
- qt_sql """ select bitmap_to_string(to_bitmap(1)) """
- qt_sql """ select bitmap_to_string(bitmap_or(to_bitmap(1), to_bitmap(2)))
"""
-
- // BITMAP_UNION
- def bitmapUnionTable = "test_bitmap_union"
- sql """ DROP TABLE IF EXISTS ${bitmapUnionTable} """
- sql """ create table if not exists ${bitmapUnionTable} (page_id
int,user_id bitmap bitmap_union) aggregate key (page_id) distributed by hash
(page_id) PROPERTIES("replication_num" = "1") """
-
- sql """ insert into ${bitmapUnionTable} values(1, to_bitmap(1)); """
- sql """ insert into ${bitmapUnionTable} values(1, to_bitmap(2)); """
- sql """ insert into ${bitmapUnionTable} values(1, to_bitmap(3)); """
- sql """ insert into ${bitmapUnionTable} values(2, to_bitmap(1)); """
- sql """ insert into ${bitmapUnionTable} values(2, to_bitmap(2)); """
-
- qt_sql """ select page_id, bitmap_union(user_id) from ${bitmapUnionTable}
group by page_id order by page_id """
- qt_sql """ select page_id, bitmap_count(bitmap_union(user_id)) from
${bitmapUnionTable} group by page_id order by page_id """
- qt_sql """ select page_id, count(distinct user_id) from
${bitmapUnionTable} group by page_id order by page_id """
-
- sql """ drop table ${bitmapUnionTable} """
-
- // BITMAP_XOR
- qt_sql """ select
bitmap_count(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')))
cnt; """
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4')));
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5')));
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),bitmap_empty()));
"""
- qt_sql """ select
bitmap_to_string(bitmap_xor(bitmap_from_string('2,3'),bitmap_from_string('1,2,3,4'),bitmap_from_string('3,4,5'),NULL));
"""
-
- // TO_BITMAP
- qt_sql """ select bitmap_count(to_bitmap(10)) """
- qt_sql """ select bitmap_to_string(to_bitmap(-1)) """
-
- // BITMAP_MAX
- qt_sql """ select bitmap_max(bitmap_from_string('')) value; """
- qt_sql """ select bitmap_max(bitmap_from_string('1,9999999999')) value """
-
- // INTERSECT_COUNT
- def intersectCountTable = "test_intersect_count"
- sql """ DROP TABLE IF EXISTS ${intersectCountTable} """
- sql """ create table if not exists ${intersectCountTable} (dt int
(11),page varchar (10),user_id bitmap BITMAP_UNION ) DISTRIBUTED BY HASH(dt)
BUCKETS 2 PROPERTIES("replication_num" = "1") """
-
-
- sql """ insert into ${intersectCountTable} values(3,"110001",
to_bitmap(1)); """
- sql """ insert into ${intersectCountTable} values(3,"110001",
to_bitmap(2)); """
- sql """ insert into ${intersectCountTable} values(3,"110001",
to_bitmap(3)); """
- sql """ insert into ${intersectCountTable} values(3,"110001",
to_bitmap(4)); """
- sql """ insert into ${intersectCountTable} values(3,"110001",
to_bitmap(5)); """
- sql """ insert into ${intersectCountTable} values(4,"110001",
to_bitmap(1)); """
- sql """ insert into ${intersectCountTable} values(4,"110001",
to_bitmap(2)); """
- sql """ insert into ${intersectCountTable} values(4,"110001",
to_bitmap(3)); """
-
- qt_sql """ select dt,bitmap_to_string(user_id) from ${intersectCountTable}
where dt in (3,4) order by dt desc; """
- qt_sql """ select intersect_count(user_id,dt,3,4) from
${intersectCountTable}; """
-
- // ARTHOGONAL_BITMAP_****
- def arthogonalBitmapTable = "test_arthogonal_bitmap"
- sql """ DROP TABLE IF EXISTS ${arthogonalBitmapTable} """
- sql """ CREATE TABLE IF NOT EXISTS ${arthogonalBitmapTable} ( tag_group
bigint(20) NULL COMMENT "标签组", tag_value_id varchar(64) NULL COMMENT "标签值",
tag_range int(11) NOT NULL DEFAULT "0" COMMENT "", partition_sign varchar(32)
NOT NULL COMMENT "分区标识", bucket int(11) NOT NULL COMMENT "分桶字段", confidence
tinyint(4) NULL DEFAULT "100" COMMENT "置信度", members bitmap BITMAP_UNION NULL
COMMENT "人群") ENGINE=OLAP AGGREGATE KEY(tag_group, tag_value_id, tag_range,
partition_sign, bucket, confiden [...]
-
- qt_sql """ select orthogonal_bitmap_intersect(members, tag_group, 1150000,
1150001, 390006) from ${arthogonalBitmapTable} where tag_group in ( 1150000,
1150001, 390006); """
- qt_sql """ select orthogonal_bitmap_intersect_count(members, tag_group,
1150000, 1150001, 390006) from ${arthogonalBitmapTable} where tag_group in (
1150000, 1150001, 390006); """
- qt_sql """ select orthogonal_bitmap_union_count(members) from
${arthogonalBitmapTable} where tag_group in ( 1150000, 1150001, 390006); """
-
- // Nereids does't support array function
- // qt_sql """ select bitmap_to_array(user_id) from ${intersectCountTable}
order by dt desc; """
- // Nereids does't support array function
- // qt_sql """ select bitmap_to_array(bitmap_empty()); """
- // Nereids does't support array function
- // qt_sql """ select bitmap_to_array(bitmap_from_string('100,200,3,4'));
"""
-
- qt_sql """ select
bitmap_to_string(sub_bitmap(bitmap_from_string('1,2,3,4,5'), 0, 3)) value; """
- qt_sql """ select bitmap_to_string(sub_bitmap(bitmap_from_string('1'), 0,
3)) value; """
- qt_sql """ select
bitmap_to_string(bitmap_subset_limit(bitmap_from_string('100'), 0, 3)) value;
"""
- qt_sql """ select
bitmap_to_string(bitmap_subset_in_range(bitmap_from_string('20221103'), 0,
20221104)) date_list_bitmap; """
-
- sql "drop table if exists d_table;"
- sql """
- create table d_table (
- k1 int null,
- k2 int not null,
- k3 bigint null,
- k4 varchar(100) null
- )
- duplicate key (k1,k2,k3)
- distributed BY hash(k1) buckets 3
- properties("replication_num" = "1");
- """
- sql "insert into d_table select -4,-4,-4,'d';"
- try_sql "select bitmap_union(to_bitmap_with_check(k2)) from d_table;"
- qt_sql "select bitmap_union(to_bitmap(k2)) from d_table;"
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]