[fix](jdbc catalog) fix and add mysql and doris extremum test #41679 (#42122)

cherry pick from #41679

---------

Co-authored-by: zy-kkk <zhongyk10@gmail.com>
This commit is contained in:
Rayner Chen
2024-10-21 16:39:40 +08:00
committed by GitHub
parent b9e2738ee6
commit a150d160ea
16 changed files with 980 additions and 46 deletions

View File

@ -352,3 +352,156 @@ col_int_undef_signed2 int
create table doris_test.text_push (pk varchar(10));
create table doris_test.all_types_nullable (
`tinyint_u` tinyint unsigned,
`smallint_u` smallint unsigned,
`mediumint_u` mediumint unsigned,
`int_u` int unsigned,
`bigint_u` bigint unsigned,
`decimal1_u` decimal unsigned,
`decimal2_u` decimal(9, 2) unsigned,
`decimal3_u` decimal(18, 5) unsigned,
`decimal4_u` decimal(38, 10) unsigned,
`decimal5_u` decimal(65, 30) unsigned,
`double_u` double unsigned,
`float_u` float unsigned,
`boolean` boolean,
`tinyint` tinyint,
`smallint` smallint,
`mediumint` mediumint,
`int` int,
`bigint` bigint,
`double` double,
`float` float,
`decimal1` decimal,
`decimal2` decimal(9, 2),
`decimal3` decimal(18, 5) ,
`decimal4` decimal(38, 10),
`decimal5` decimal(65, 30),
`year` year,
`time1` time,
`time2` time(3),
`time3` time(6),
`date` date,
`datetime` datetime,
`timestamp1` timestamp null,
`timestamp2` timestamp(3) null,
`timestamp3` timestamp(6) null,
`char` char(5),
`varchar` varchar(10),
`text` text,
`blob` blob,
`json` json,
`set` set('Option1', 'Option2', 'Option3'),
`bit` bit(6),
`binary` binary(12),
`varbinary` varbinary(12),
`enum` enum('Value1', 'Value2', 'Value3')
) engine=innodb charset=utf8;
create table doris_test.all_types_non_nullable (
`tinyint_u` tinyint unsigned NOT NULL,
`smallint_u` smallint unsigned NOT NULL,
`mediumint_u` mediumint unsigned NOT NULL,
`int_u` int unsigned NOT NULL,
`bigint_u` bigint unsigned NOT NULL,
`decimal1_u` decimal unsigned NOT NULL,
`decimal2_u` decimal(9, 2) unsigned NOT NULL,
`decimal3_u` decimal(18, 5) unsigned NOT NULL,
`decimal4_u` decimal(38, 10) unsigned NOT NULL,
`decimal5_u` decimal(65, 30) unsigned NOT NULL,
`double_u` double unsigned NOT NULL,
`float_u` float unsigned NOT NULL,
`boolean` boolean NOT NULL,
`tinyint` tinyint NOT NULL,
`smallint` smallint NOT NULL,
`mediumint` mediumint NOT NULL,
`int` int NOT NULL,
`bigint` bigint NOT NULL,
`double` double NOT NULL,
`float` float NOT NULL,
`decimal1` decimal NOT NULL,
`decimal2` decimal(9, 2) NOT NULL,
`decimal3` decimal(18, 5) NOT NULL,
`decimal4` decimal(38, 10) NOT NULL,
`decimal5` decimal(65, 30) NOT NULL,
`year` year NOT NULL,
`time1` time NOT NULL,
`time2` time(3) NOT NULL,
`time3` time(6) NOT NULL,
`date` date NOT NULL,
`datetime` datetime NOT NULL,
`timestamp1` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`timestamp2` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`timestamp3` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
`char` char(5) NOT NULL,
`varchar` varchar(10) NOT NULL,
`text` text NOT NULL,
`blob` blob NOT NULL,
`json` json NOT NULL,
`set` set('Option1', 'Option2', 'Option3') NOT NULL,
`bit` bit(6) NOT NULL,
`binary` binary(12) NOT NULL,
`varbinary` varbinary(12) NOT NULL,
`enum` enum('Value1', 'Value2', 'Value3') NOT NULL
) engine=innodb charset=utf8;
create table doris_test.all_types_multi_block (
`tinyint_u` tinyint unsigned,
`smallint_u` smallint unsigned,
`mediumint_u` mediumint unsigned,
`int_u` int unsigned,
`bigint_u` bigint unsigned,
`decimal1_u` decimal unsigned,
`decimal2_u` decimal(9, 2) unsigned,
`decimal3_u` decimal(18, 5) unsigned,
`decimal4_u` decimal(38, 10) unsigned,
`decimal5_u` decimal(65, 30) unsigned,
`double_u` double unsigned,
`float_u` float unsigned,
`boolean` boolean,
`tinyint` tinyint,
`smallint` smallint,
`mediumint` mediumint,
`int` int,
`bigint` bigint,
`double` double,
`float` float,
`decimal1` decimal,
`decimal2` decimal(9, 2),
`decimal3` decimal(18, 5) ,
`decimal4` decimal(38, 10),
`decimal5` decimal(65, 30),
`year` year,
`time1` time,
`time2` time(3),
`time3` time(6),
`date` date,
`datetime` datetime,
`timestamp1` timestamp null,
`timestamp2` timestamp(3) null,
`timestamp3` timestamp(6) null,
`char` char(5),
`varchar` varchar(10),
`text` text,
`blob` blob,
`json` json,
`set` set('Option1', 'Option2', 'Option3'),
`bit` bit(6),
`binary` binary(12),
`varbinary` varbinary(12),
`enum` enum('Value1', 'Value2', 'Value3')
) engine=innodb charset=utf8;
CREATE TABLE doris_test.`t_varchar` (
`varchar_col` varchar(21844)
);
CREATE TABLE doris_test.`t_char` (
`char_col` char(255) COLLATE utf8_bin DEFAULT NULL
);

View File

@ -1168,3 +1168,40 @@ insert into Doris.doris values ('doris');
insert into doris_test.compoundpredicate_test(pk,col_int_undef_signed,col_int_undef_signed2) values (0,null,23868),(1,68,-18),(2,19030,-125),(3,16539,null),(4,null,null),(5,null,-127),(6,14680,-26424),(7,-22270,12722),(8,null,null),(9,null,null),(10,null,7744),(11,null,-94),(12,16970,95),(13,null,7023),(14,null,1),(15,3679,-11),(16,null,-1079),(17,-22,null),(18,30995,null),(19,null,-79);
insert into doris_test.text_push values('a'),('aa'),('aaa');
insert into doris_test.all_types_nullable
values(0,0,0,0,0, 0, 0.00, 0.00000, 0.0000000000, 0.000000000000000000000000000000,0,0,false,-128,-32768,-8388608,-2147483648,-9223372036854775808,-1.7976931348623157E+308,-3.4028234E+38,-9999999999,-9999999.99,-9999999999999.99999,-9999999999999999999999999999.9999999999,-99999999999999999999999999999999999.999999999999999999999999999999,1901,'-838:59:59','-838:59:59.000','-838:59:59.000000','1000-01-01','1000-01-01 00:00:00','1970-01-01 00:00:01','1970-01-01 00:00:01.000','1970-01-01 00:00:01.000000','','','', '', '{}', '', b'000000', '', '', 'Value1'),
(255,65535,16777215,4294967295,18446744073709551615,9999999999, 9999999.99, 9999999999999.99999, 9999999999999999999999999999.9999999999, 99999999999999999999999999999999999.999999999999999999999999999999,1.7976931348623157E+308,3.4028234E+38,true,127,32767,8388607,2147483647,9223372036854775807,1.7976931348623157E+308,3.4028234E+38,9999999999,9999999.99,9999999999999.99999,9999999999999999999999999999.9999999999,99999999999999999999999999999999999.999999999999999999999999999999,2155,'838:59:59.000','838:59:59.000','838:59:59.000000','9999-12-31','9999-12-31 23:59:59','2038-01-19 03:14:07','2038-01-19 03:14:07.499','2038-01-19 03:14:07.499999','zzzz','abcdefgh','max', 'maxBLOB', '{"key": "maxJSON"}', 'Option1,Option2,Option3', b'111111', 'maxBIN', 'maxVARBIN', 'Value3'),
(0,0,0,0,0, 0, 0.00, 0.00000, 0.0000000000, 0.000000000000000000000000000000, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1901, '00:00:00', '00:00:00.000', '00:00:00.000000','1000-01-01','1000-01-01 00:00:00','1970-01-01 00:00:01','1970-01-01 00:00:01.000','1970-01-01 00:00:01.000000', '', '', '', '', '{}', '', b'', '', '', 'Value1'),
(NULL,NULL,NULL,NULL,NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
insert into doris_test.all_types_non_nullable
values(0,0,0,0,0, 0, 0.00, 0.00000, 0.0000000000, 0.000000000000000000000000000000,0,0,false,-128,-32768,-8388608,-2147483648,-9223372036854775808,-1.7976931348623157E+308,-3.4028234E+38,-9999999999,-9999999.99,-9999999999999.99999,-9999999999999999999999999999.9999999999,-99999999999999999999999999999999999.999999999999999999999999999999,1901,'-838:59:59','-838:59:59.000','-838:59:59.000000','1000-01-01','1000-01-01 00:00:00','1970-01-01 00:00:01','1970-01-01 00:00:01.000','1970-01-01 00:00:01.000000','','','', '', '{}', '', b'000000', '', '', 'Value1'),
(255,65535,16777215,4294967295,18446744073709551615,9999999999, 9999999.99, 9999999999999.99999, 9999999999999999999999999999.9999999999, 99999999999999999999999999999999999.999999999999999999999999999999,1.7976931348623157E+308,3.4028234E+38,true,127,32767,8388607,2147483647,9223372036854775807,1.7976931348623157E+308,3.4028234E+38,9999999999,9999999.99,9999999999999.99999,9999999999999999999999999999.9999999999,99999999999999999999999999999999999.999999999999999999999999999999,2155,'838:59:59.000','838:59:59.000','838:59:59.000000','9999-12-31','9999-12-31 23:59:59','2038-01-19 03:14:07','2038-01-19 03:14:07.499','2038-01-19 03:14:07.499999','zzzz','abcdefgh','max', 'maxBLOB', '{"key": "maxJSON"}', 'Option1,Option2,Option3', b'111111', 'maxBIN', 'maxVARBIN', 'Value3'),
(0,0,0,0,0, 0, 0.00, 0.00000, 0.0000000000, 0.000000000000000000000000000000, 0, 0, false, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1901, '00:00:00', '00:00:00.000', '00:00:00.000000','1000-01-01','1000-01-01 00:00:00','1970-01-01 00:00:01','1970-01-01 00:00:01.000','1970-01-01 00:00:01.000000', '', '', '', '', '{}', '', b'', '', '', 'Value1');
insert into doris_test.all_types_multi_block select * from doris_test.all_types_nullable;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_multi_block;
insert into doris_test.all_types_multi_block select * from doris_test.all_types_nullable;
INSERT INTO doris_test.t_varchar (varchar_col) VALUES ('a');
INSERT INTO doris_test.t_varchar (varchar_col) VALUES ('');
INSERT INTO doris_test.t_varchar (varchar_col) VALUES (REPEAT('a', 21844));
INSERT INTO doris_test.t_varchar (varchar_col) VALUES (REPEAT('', 21844));
INSERT INTO doris_test.t_char (char_col) VALUES (REPEAT('a', 255));
INSERT INTO doris_test.t_char (char_col) VALUES (REPEAT('', 255));

View File

@ -57,8 +57,8 @@ public abstract class BaseJdbcExecutor implements JdbcExecutor {
private static final TBinaryProtocol.Factory PROTOCOL_FACTORY = new TBinaryProtocol.Factory();
private HikariDataSource hikariDataSource = null;
private final byte[] hikariDataSourceLock = new byte[0];
private JdbcDataSourceConfig config;
private Connection conn = null;
protected JdbcDataSourceConfig config;
protected PreparedStatement preparedStatement = null;
protected Statement stmt = null;
protected ResultSet resultSet = null;

View File

@ -22,6 +22,7 @@ import org.apache.doris.common.jni.vec.ColumnType.Type;
import org.apache.doris.common.jni.vec.ColumnValueConverter;
import org.apache.doris.common.jni.vec.VectorTable;
import org.apache.doris.thrift.TJdbcOperation;
import org.apache.doris.thrift.TOdbcTableType;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.MoreExecutors;
@ -34,6 +35,7 @@ import java.math.BigInteger;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatterBuilder;
@ -133,8 +135,18 @@ public class MySQLJdbcExecutor extends BaseJdbcExecutor {
case VARCHAR:
case ARRAY:
return resultSet.getObject(columnIndex + 1, String.class);
case STRING:
return resultSet.getObject(columnIndex + 1);
case STRING: {
int jdbcType = resultSetMetaData.getColumnType(columnIndex + 1);
// If it is a time type in mysql, or use mysql driver connect mariadb
// We need to obtain the string directly to ensure that we can obtain a time other than 24 hours.
// If it is another database, such as oceanbase, this processing will lose precision information,
// so the original processing method will be maintained for the time being.
if (jdbcType == Types.TIME && config.getTableType() == TOdbcTableType.MYSQL) {
return resultSet.getString(columnIndex + 1);
} else {
return resultSet.getObject(columnIndex + 1);
}
}
default:
throw new IllegalArgumentException("Unsupported column type: " + type.getType());
}
@ -192,6 +204,9 @@ public class MySQLJdbcExecutor extends BaseJdbcExecutor {
}
private Object convertArray(Object input, ColumnType columnType) {
if (input == null) {
return null;
}
java.lang.reflect.Type listType = getListTypeForArray(columnType);
if (columnType.getType() == Type.BOOLEAN) {
List<?> list = gson.fromJson((String) input, List.class);
@ -228,10 +243,25 @@ public class MySQLJdbcExecutor extends BaseJdbcExecutor {
throw new IllegalArgumentException("Cannot convert " + item + " to LocalDateTime.");
}
}).collect(Collectors.toList());
} else if (columnType.getType() == Type.LARGEINT) {
List<?> list = gson.fromJson((String) input, List.class);
return list.stream().map(item -> {
if (item instanceof Number) {
return new BigDecimal(item.toString()).toBigInteger();
} else if (item instanceof String) {
return new BigDecimal((String) item).toBigInteger();
} else {
throw new IllegalArgumentException("Cannot convert " + item + " to BigInteger.");
}
}).collect(Collectors.toList());
} else if (columnType.getType() == Type.ARRAY) {
List<?> list = gson.fromJson((String) input, listType);
return list.stream()
.map(item -> convertArray(gson.toJson(item), columnType.getChildTypes().get(0)))
ColumnType childType = columnType.getChildTypes().get(0);
List<?> rawList = gson.fromJson((String) input, List.class);
return rawList.stream()
.map(element -> {
String elementJson = gson.toJson(element);
return convertArray(elementJson, childType);
})
.collect(Collectors.toList());
} else {
return gson.fromJson((String) input, listType);

View File

@ -195,8 +195,8 @@ public class JdbcMySQLClient extends JdbcClient {
case "BIGINT":
return Type.LARGEINT;
case "DECIMAL": {
int precision = fieldSchema.getColumnSize().orElse(0) + 1;
int scale = fieldSchema.getDecimalDigits().orElse(0);
int precision = fieldSchema.requiredColumnSize() + 1;
int scale = fieldSchema.requiredDecimalDigits();
return createDecimalOrStringType(precision, scale);
}
case "DOUBLE":
@ -233,7 +233,7 @@ public class JdbcMySQLClient extends JdbcClient {
case "DATETIME": {
// mysql can support microsecond
// use columnSize to calculate the precision of timestamp/datetime
int columnSize = fieldSchema.getColumnSize().orElse(0);
int columnSize = fieldSchema.requiredColumnSize();
int scale = columnSize > 19 ? columnSize - 20 : 0;
if (scale > 6) {
scale = 6;
@ -248,18 +248,18 @@ public class JdbcMySQLClient extends JdbcClient {
case "DOUBLE":
return Type.DOUBLE;
case "DECIMAL": {
int precision = fieldSchema.getColumnSize().orElse(0);
int scale = fieldSchema.getDecimalDigits().orElse(0);
int precision = fieldSchema.requiredColumnSize();
int scale = fieldSchema.requiredDecimalDigits();
return createDecimalOrStringType(precision, scale);
}
case "CHAR":
ScalarType charType = ScalarType.createType(PrimitiveType.CHAR);
charType.setLength(fieldSchema.getColumnSize().orElse(0));
charType.setLength(fieldSchema.requiredColumnSize());
return charType;
case "VARCHAR":
return ScalarType.createVarcharType(fieldSchema.getColumnSize().orElse(0));
case "BIT":
if (fieldSchema.getColumnSize().orElse(0) == 1) {
if (fieldSchema.requiredColumnSize() == 1) {
return Type.BOOLEAN;
} else {
return ScalarType.createStringType();
@ -360,8 +360,8 @@ public class JdbcMySQLClient extends JdbcClient {
return Type.DOUBLE;
case "DECIMAL":
case "DECIMALV3": {
int precision = fieldSchema.getColumnSize().orElse(0);
int scale = fieldSchema.getDecimalDigits().orElse(0);
int precision = fieldSchema.requiredColumnSize();
int scale = fieldSchema.requiredDecimalDigits();
return createDecimalOrStringType(precision, scale);
}
case "DATE":
@ -377,11 +377,12 @@ public class JdbcMySQLClient extends JdbcClient {
return ScalarType.createDatetimeV2Type(scale);
}
case "CHAR":
case "CHARACTER":
ScalarType charType = ScalarType.createType(PrimitiveType.CHAR);
charType.setLength(fieldSchema.getColumnSize().orElse(0));
charType.setLength(fieldSchema.requiredColumnSize());
return charType;
case "VARCHAR":
return ScalarType.createVarcharType(fieldSchema.getColumnSize().orElse(0));
return ScalarType.createVarcharType(fieldSchema.requiredColumnSize());
case "STRING":
case "TEXT":
case "JSON":

View File

@ -47,7 +47,6 @@ public class JdbcFieldSchema {
protected int charOctetLength;
protected boolean isAllowNull;
public JdbcFieldSchema(JdbcFieldSchema other) {
this.columnName = other.columnName;
this.dataType = other.dataType;
@ -65,7 +64,7 @@ public class JdbcFieldSchema {
this.dataType = getInteger(rs, "DATA_TYPE").orElseThrow(() -> new IllegalStateException("DATA_TYPE is null"));
this.dataTypeName = Optional.ofNullable(rs.getString("TYPE_NAME"));
this.columnSize = getInteger(rs, "COLUMN_SIZE");
this.decimalDigits = getInteger(rs, "DECIMAL_DIGITS");
this.decimalDigits = getInteger(rs, "DECIMAL_DIGITS");
this.numPrecRadix = rs.getInt("NUM_PREC_RADIX");
this.isAllowNull = rs.getInt("NULLABLE") != DatabaseMetaData.columnNoNulls;
this.remarks = rs.getString("REMARKS");
@ -77,7 +76,7 @@ public class JdbcFieldSchema {
this.dataType = getInteger(rs, "DATA_TYPE").orElseThrow(() -> new IllegalStateException("DATA_TYPE is null"));
this.dataTypeName = Optional.ofNullable(dataTypeOverrides.getOrDefault(columnName, rs.getString("TYPE_NAME")));
this.columnSize = getInteger(rs, "COLUMN_SIZE");
this.decimalDigits = getInteger(rs, "DECIMAL_DIGITS");
this.decimalDigits = getInteger(rs, "DECIMAL_DIGITS");
this.numPrecRadix = rs.getInt("NUM_PREC_RADIX");
this.isAllowNull = rs.getInt("NULLABLE") != 0;
this.remarks = rs.getString("REMARKS");
@ -92,6 +91,14 @@ public class JdbcFieldSchema {
this.decimalDigits = Optional.of(metaData.getScale(columnIndex));
}
public int requiredColumnSize() {
return columnSize.orElseThrow(() -> new IllegalStateException("column size not present"));
}
public int requiredDecimalDigits() {
return decimalDigits.orElseThrow(() -> new IllegalStateException("decimal digits not present"));
}
protected static Optional<Integer> getInteger(ResultSet resultSet, String columnLabel)
throws SQLException {
int value = resultSet.getInt(columnLabel);
@ -101,4 +108,3 @@ public class JdbcFieldSchema {
return Optional.of(value);
}
}

View File

@ -37,8 +37,8 @@ processlist
2023-06-17T10:00 2023-06-17T10:00:01 2023-06-17T10:00:02.200 2023-06-17T10:00:03.330 2023-06-17T10:00:04.444 2023-06-17T10:00:05.555500 2023-06-17T10:00:06.666660 2023-06-17T10:00:06.666666
-- !mysql_all_types --
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345600 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345600 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.567 text1 0x48656C6C6F20576F726C64 {"name": "Alice", "age": 30, "city": "London"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345600 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 {"name": "Gaoxin", "age": 18, "city": "ChongQing"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"name": "ChenQi", "age": 24, "city": "ChongQing"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345600 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345600 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.5678 text1 0x48656C6C6F20576F726C64 {"name": "Alice", "age": 30, "city": "London"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345600 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 {"name": "Gaoxin", "age": 18, "city": "ChongQing"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.5678 text3 0xE86F6C6C6F20576F726C67 {"name": "ChenQi", "age": 24, "city": "ChongQing"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1

View File

@ -262,22 +262,22 @@ mysql
4
-- !mysql_all_types --
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.567 text1 0x48656C6C6F20576F726C64 {"age": 30, "city": "London", "name": "Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 {"age": 18, "city": "ChongQing", "name": "Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age": 24, "city": "ChongQing", "name": "ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.5678 text1 0x48656C6C6F20576F726C64 {"age": 30, "city": "London", "name": "Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 {"age": 18, "city": "ChongQing", "name": "Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.5678 text3 0xE86F6C6C6F20576F726C67 {"age": 24, "city": "ChongQing", "name": "ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
-- !select_insert_all_types --
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.567 text1 0x48656C6C6F20576F726C64 {"age":30,"city":"London","name":"Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 {"age":18,"city":"ChongQing","name":"Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age":24,"city":"ChongQing","name":"ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.5678 text1 0x48656C6C6F20576F726C64 {"age":30,"city":"London","name":"Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 {"age":18,"city":"ChongQing","name":"Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.5678 text3 0xE86F6C6C6F20576F726C67 {"age":24,"city":"ChongQing","name":"ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
-- !ctas --
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.567 text1 0x48656C6C6F20576F726C64 {"age": 30, "city": "London", "name": "Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.567 text2 0xE86F6C6C6F20576F726C67 {"age": 18, "city": "ChongQing", "name": "Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.567 text3 0xE86F6C6C6F20576F726C67 {"age": 24, "city": "ChongQing", "name": "ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
\N 302 \N 502 602 4.14159 \N 6.14159 \N -124 -302 2013 -402 -502 -602 \N 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 \N -7.1400 row2 \N 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 \N \N 0x2F \N 0x88656C6C9F Value3
201 301 401 501 601 3.14159 4.1415926 5.14159 1 -123 -301 2012 -401 -501 -601 2012-10-30 2012-10-25T12:05:36.345700 2012-10-25T08:08:08 -4.14145 -5.1400000001 -6.1400 row1 line1 09:09:09.5678 text1 0x48656C6C6F20576F726C64 {"age": 30, "city": "London", "name": "Alice"} Option1,Option3 0x2A 0x48656C6C6F00000000000000 0x48656C6C6F Value2
202 302 402 502 602 4.14159 5.1415926 6.14159 0 -124 -302 2013 -402 -502 -602 2012-11-01 2012-10-26T02:08:39.345700 2013-10-26T08:09:18 -5.14145 -6.1400000001 -7.1400 row2 line2 09:11:09.5678 text2 0xE86F6C6C6F20576F726C67 {"age": 18, "city": "ChongQing", "name": "Gaoxin"} Option1,Option2 0x2F 0x58676C6C6F00000000000000 0x88656C6C9F Value3
203 303 403 503 603 7.14159 8.1415926 9.14159 0 \N -402 2017 -602 -902 -1102 2012-11-02 \N 2013-10-27T08:11:18 -5.14145 -6.1400000000001 -7.1400 row3 line3 09:11:09.5678 text3 0xE86F6C6C6F20576F726C67 {"age": 24, "city": "ChongQing", "name": "ChenQi"} Option2 0x2F 0x58676C6C6F00000000000000 \N Value1
-- !ctas_desc --
bigint bigint Yes false \N NONE
@ -445,12 +445,3 @@ t2 text Yes false \N NONE
varchar varchar(65533) Yes true \N
int_u bigint Yes false \N NONE
-- !sql --
int_u bigint Yes true \N
text varchar(65533) Yes true \N
t2 varchar(65533) Yes false \N NONE
-- !sql --
varchar varchar(65533) Yes true \N
int_u bigint Yes false \N NONE

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,104 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !desc_tvf_all_types_null --
tinyint_u smallint Yes true \N NONE
smallint_u int Yes true \N NONE
mediumint_u int Yes true \N NONE
int_u bigint Yes true \N NONE
bigint_u largeint Yes true \N NONE
decimal1_u decimal(11,0) Yes true \N NONE
decimal2_u decimal(10,2) Yes true \N NONE
decimal3_u decimal(19,5) Yes true \N NONE
decimal4_u text Yes true \N NONE
decimal5_u text Yes true \N NONE
double_u double Yes true \N NONE
float_u float Yes true \N NONE
boolean tinyint Yes true \N NONE
tinyint tinyint Yes true \N NONE
smallint smallint Yes true \N NONE
mediumint int Yes true \N NONE
int int Yes true \N NONE
bigint bigint Yes true \N NONE
double double Yes true \N NONE
float float Yes true \N NONE
decimal1 decimal(10,0) Yes true \N NONE
decimal2 decimal(9,2) Yes true \N NONE
decimal3 decimal(18,5) Yes true \N NONE
decimal4 decimal(38,10) Yes true \N NONE
decimal5 text Yes true \N NONE
year smallint Yes true \N NONE
time1 text Yes true \N NONE
time2 text Yes true \N NONE
time3 text Yes true \N NONE
date date Yes true \N NONE
datetime datetime Yes true \N NONE
timestamp1 datetime Yes true \N NONE
timestamp2 datetime(3) Yes true \N NONE
timestamp3 datetime(6) Yes true \N NONE
char char(6) Yes true \N NONE
varchar varchar(10) Yes true \N NONE
text text Yes true \N NONE
blob text Yes true \N NONE
json text Yes true \N NONE
set char(6) Yes true \N NONE
bit text Yes true \N NONE
binary text Yes true \N NONE
varbinary text Yes true \N NONE
enum char(6) Yes true \N NONE
-- !tvf_null_all_types_null --
\N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N
0 0 0 0 0 0 0.00 0.00000 0E-10 0E-30 0.0 0.0 0 -128 -32768 -8388608 -2147483648 -9223372036854775808 -1.7976931348623157E308 -3.40282E38 -9999999999 -9999999.99 -9999999999999.99999 -9999999999999999999999999999.9999999999 -99999999999999999999999999999999999.999999999999999999999999999999 1901 -838:59:59 -838:59:59 -838:59:59 1000-01-01 1000-01-01T00:00 1970-01-01T00:00:01 1970-01-01T00:00:01 1970-01-01T00:00:01 0x {} 0x00 0x000000000000000000000000 0x Value1
0 0 0 0 0 0 0.00 0.00000 0E-10 0E-30 0.0 0.0 0 0 0 0 0 0 0.0 0.0 0 0.00 0.00000 0E-10 0E-30 1901 00:00:00 00:00:00 00:00:00 1000-01-01 1000-01-01T00:00 1970-01-01T00:00:01 1970-01-01T00:00:01 1970-01-01T00:00:01 0x {} 0x00 0x000000000000000000000000 0x Value1
255 65535 16777215 4294967295 18446744073709551615 9999999999 9999999.99 9999999999999.99999 9999999999999999999999999999.9999999999 99999999999999999999999999999999999.999999999999999999999999999999 1.7976931348623157E308 3.40282E38 1 127 32767 8388607 2147483647 9223372036854775807 1.7976931348623157E308 3.40282E38 9999999999 9999999.99 9999999999999.99999 9999999999999999999999999999.9999999999 99999999999999999999999999999999999.999999999999999999999999999999 2155 838:59:59 838:59:59 838:59:59 9999-12-31 9999-12-31T23:59:59 2038-01-19T03:14:07 2038-01-19T03:14:07.499 2038-01-19T03:14:07.499999 zzzz abcdefgh max 0x6D6178424C4F42 {"key": "maxJSON"} Option1,Option2,Option3 0x3F 0x6D617842494E000000000000 0x6D617856415242494E Value3
-- !desc_tvf_all_types_non_null --
tinyint_u smallint Yes true \N NONE
smallint_u int Yes true \N NONE
mediumint_u int Yes true \N NONE
int_u bigint Yes true \N NONE
bigint_u largeint Yes true \N NONE
decimal1_u decimal(11,0) Yes true \N NONE
decimal2_u decimal(10,2) Yes true \N NONE
decimal3_u decimal(19,5) Yes true \N NONE
decimal4_u text Yes true \N NONE
decimal5_u text Yes true \N NONE
double_u double Yes true \N NONE
float_u float Yes true \N NONE
boolean tinyint Yes true \N NONE
tinyint tinyint Yes true \N NONE
smallint smallint Yes true \N NONE
mediumint int Yes true \N NONE
int int Yes true \N NONE
bigint bigint Yes true \N NONE
double double Yes true \N NONE
float float Yes true \N NONE
decimal1 decimal(10,0) Yes true \N NONE
decimal2 decimal(9,2) Yes true \N NONE
decimal3 decimal(18,5) Yes true \N NONE
decimal4 decimal(38,10) Yes true \N NONE
decimal5 text Yes true \N NONE
year smallint Yes true \N NONE
time1 text Yes true \N NONE
time2 text Yes true \N NONE
time3 text Yes true \N NONE
date date Yes true \N NONE
datetime datetime Yes true \N NONE
timestamp1 datetime Yes true \N NONE
timestamp2 datetime(3) Yes true \N NONE
timestamp3 datetime(6) Yes true \N NONE
char char(6) Yes true \N NONE
varchar varchar(10) Yes true \N NONE
text text Yes true \N NONE
blob text Yes true \N NONE
json text Yes true \N NONE
set char(6) Yes true \N NONE
bit text Yes true \N NONE
binary text Yes true \N NONE
varbinary text Yes true \N NONE
enum char(6) Yes true \N NONE
-- !tvf_null_all_types_non_null --
0 0 0 0 0 0 0.00 0.00000 0E-10 0E-30 0.0 0.0 0 -128 -32768 -8388608 -2147483648 -9223372036854775808 -1.7976931348623157E308 -3.40282E38 -9999999999 -9999999.99 -9999999999999.99999 -9999999999999999999999999999.9999999999 -99999999999999999999999999999999999.999999999999999999999999999999 1901 -838:59:59 -838:59:59 -838:59:59 1000-01-01 1000-01-01T00:00 1970-01-01T00:00:01 1970-01-01T00:00:01 1970-01-01T00:00:01 0x {} 0x00 0x000000000000000000000000 0x Value1
0 0 0 0 0 0 0.00 0.00000 0E-10 0E-30 0.0 0.0 0 0 0 0 0 0 0.0 0.0 0 0.00 0.00000 0E-10 0E-30 1901 00:00:00 00:00:00 00:00:00 1000-01-01 1000-01-01T00:00 1970-01-01T00:00:01 1970-01-01T00:00:01 1970-01-01T00:00:01 0x {} 0x00 0x000000000000000000000000 0x Value1
255 65535 16777215 4294967295 18446744073709551615 9999999999 9999999.99 9999999999999.99999 9999999999999999999999999999.9999999999 99999999999999999999999999999999999.999999999999999999999999999999 1.7976931348623157E308 3.40282E38 1 127 32767 8388607 2147483647 9223372036854775807 1.7976931348623157E308 3.40282E38 9999999999 9999999.99 9999999999999.99999 9999999999999999999999999999.9999999999 99999999999999999999999999999999999.999999999999999999999999999999 2155 838:59:59 838:59:59 838:59:59 9999-12-31 9999-12-31T23:59:59 2038-01-19T03:14:07 2038-01-19T03:14:07.499 2038-01-19T03:14:07.499999 zzzz abcdefgh max 0x6D6178424C4F42 {"key": "maxJSON"} Option1,Option2,Option3 0x3F 0x6D617842494E000000000000 0x6D617856415242494E Value3

View File

@ -0,0 +1,61 @@
// 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_mysql_all_types_ctas", "p0,external,mysql,external_docker,external_docker_mysql") {
String enabled = context.config.otherConfigs.get("enableJdbcTest")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"
if (enabled != null && enabled.equalsIgnoreCase("true")) {
String mysql_port = context.config.otherConfigs.get("mysql_57_port");
sql """drop database if exists test_mysql_all_types_ctas;"""
sql """create database if not exists test_mysql_all_types_ctas;"""
sql """drop catalog if exists mysql_all_type_ctas_test """
sql """create catalog if not exists mysql_all_type_ctas_test properties(
"type"="jdbc",
"user"="root",
"password"="123456",
"jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}/doris_test?useSSL=false",
"driver_url" = "${driver_url}",
"driver_class" = "com.mysql.cj.jdbc.Driver"
);"""
sql """use internal.test_mysql_all_types_ctas;"""
sql """create table all_types_nullable properties("replication_num" = "1") as select * from mysql_all_type_ctas_test.doris_test.all_types_nullable;"""
qt_select_all_types_nullable """select * from internal.test_mysql_all_types_ctas.all_types_nullable order by 1;"""
sql """create table all_types_non_nullable properties("replication_num" = "1") as select * from mysql_all_type_ctas_test.doris_test.all_types_non_nullable;"""
qt_select_all_types_non_nullable """select * from internal.test_mysql_all_types_ctas.all_types_non_nullable order by 1;"""
sql """create table t_varchar properties("replication_num" = "1") as select * from mysql_all_type_ctas_test.doris_test.t_varchar;"""
qt_select_varchar """select * from internal.test_mysql_all_types_ctas.t_varchar order by 1;"""
sql """create table t_char properties("replication_num" = "1") as select * from mysql_all_type_ctas_test.doris_test.t_char;"""
qt_select_char """select * from internal.test_mysql_all_types_ctas.t_char order by 1;"""
sql """drop database if exists test_mysql_all_types_ctas;"""
}
}

View File

@ -0,0 +1,208 @@
// 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_doris_all_types_select", "p0,external,doris,external_docker,external_docker_doris") {
String jdbcUrl = context.config.jdbcUrl + "&sessionVariables=return_object_data_as_binary=true"
String jdbcUser = context.config.jdbcUser
String jdbcPassword = context.config.jdbcPassword
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String doris_port = context.config.otherConfigs.get("doris_port");
sql """create database if not exists test_doris_all_types_select;"""
sql """use internal.test_doris_all_types_select;"""
sql """drop table if exists all_types_nullable"""
sql """
create table all_types_nullable (
bool_col boolean,
tinyint_col tinyint,
smallint_col smallint,
int_col int,
bigint_col bigint,
largeint_col largeint,
float_col float,
double_col double,
decimal_col decimal(38, 10),
date_col date,
datetime_col1 datetime,
datetime_col2 datetime(3),
datetime_col3 datetime(6),
char_col char(255),
varchar_col varchar(65533),
string_col string,
json_col json,
)
DUPLICATE KEY(`bool_col`)
DISTRIBUTED BY HASH(`bool_col`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """set repeat_max_num = 65533;"""
sql """insert into all_types_nullable values (false, -128, -32768, -2147483648, -9223372036854775808, -170141183460469231731687303715884105727, -3.4028234e+38, -1.7976931348623157e+308, -9999999999999999999999999999.9999999999, '0000-01-01', '0000-01-01 00:00:00', '0000-01-01 00:00:00.000', '0000-01-01 00:00:00.000000', 'a', 'a', '-string', '{\"a\": 0}');"""
sql """insert into all_types_nullable values (true, 127, 32767, 2147483647, 9223372036854775807, 170141183460469231731687303715884105727, 3.4028234e+38, 1.7976931348623157e+308, 9999999999999999999999999999.9999999999, '9999-12-31', '9999-12-31 23:59:59', '9999-12-31 23:59:59.999', '9999-12-31 23:59:59.999999', REPEAT('a', 255), REPEAT('a', 65533), '+string', '{\"a\": 1}');"""
sql """insert into all_types_nullable values (null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);"""
sql """drop table if exists all_types_non_nullable"""
sql """
create table all_types_non_nullable (
bool_col boolean not null,
tinyint_col tinyint not null,
smallint_col smallint not null,
int_col int not null,
bigint_col bigint not null,
largeint_col largeint not null,
float_col float not null,
double_col double not null,
decimal_col decimal(38, 10) not null,
date_col date not null,
datetime_col1 datetime not null,
datetime_col2 datetime(3) not null,
datetime_col3 datetime(6) not null,
char_col char(255) not null,
varchar_col varchar(65533) not null,
string_col string not null,
json_col json not null,
)
DUPLICATE KEY(`bool_col`)
DISTRIBUTED BY HASH(`bool_col`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """set repeat_max_num = 65533;"""
sql """insert into all_types_non_nullable values (false, -128, -32768, -2147483648, -9223372036854775808, -170141183460469231731687303715884105727, -3.4028234e+38, -1.7976931348623157e+308, -9999999999999999999999999999.9999999999, '0000-01-01', '0000-01-01 00:00:00', '0000-01-01 00:00:00.000', '0000-01-01 00:00:00.000000', 'a', 'a', '-string', '{\"a\": 0}');"""
sql """insert into all_types_non_nullable values (true, 127, 32767, 2147483647, 9223372036854775807, 170141183460469231731687303715884105727, 3.4028234e+38, 1.7976931348623157e+308, 9999999999999999999999999999.9999999999, '9999-12-31', '9999-12-31 23:59:59', '9999-12-31 23:59:59.999', '9999-12-31 23:59:59.999999', REPEAT('a', 255), REPEAT('a', 65533), '+string', '{\"a\": 1}');"""
sql """drop table if exists t_hll_bitmap"""
sql """
create table t_hll_bitmap (
k int,
bitmap_c bitmap BITMAP_UNION,
hll_c hll HLL_UNION
)
aggregate key (k)
distributed by hash(k) buckets 1
PROPERTIES (
"replication_num" = "1"
);
"""
sql """insert into t_hll_bitmap values (1, to_bitmap(1), hll_hash(1));"""
sql """insert into t_hll_bitmap values (2, to_bitmap(2), hll_hash(2));"""
sql """insert into t_hll_bitmap values (3, to_bitmap(3), hll_hash(3));"""
sql """insert into t_hll_bitmap values (4, to_bitmap(4), hll_hash(4));"""
sql """drop table if exists arr_types_test """
sql """
create table arr_types_test (
int_col int,
arr_bool_col array<boolean>,
arr_tinyint_col array<tinyint>,
arr_smallint_col array<smallint>,
arr_int_col array<int>,
arr_bigint_col array<bigint>,
arr_largeint_col array<largeint>,
arr_float_col array<float>,
arr_double_col array<double>,
arr_decimal1_col array<decimal(10, 5)>,
arr_decimal2_col array<decimal(30, 10)>,
arr_date_col array<date>,
arr_datetime_col array<datetime(3)>,
arr_char_col array<char(10)>,
arr_varchar_col array<varchar(10)>,
arr_string_col array<string>
)
DUPLICATE KEY(`int_col`)
DISTRIBUTED BY HASH(`int_col`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """insert into arr_types_test values (1, array(true), array(1), array(1), array(1), array(1), array(1), array(1.0), array(1.0), array(1.0), array(1.0), array('2021-01-01'), array('2021-01-01 00:00:00.000'), array('a'), array('a'), array('a'));"""
sql """insert into arr_types_test values (2, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);"""
sql """drop table if exists arr_nesting_types_test """
sql """
create table arr_nesting_types_test (
int_col int,
arr_arr_bool_col array<array<boolean>>,
arr_arr_tinyint_col array<array<tinyint>>,
arr_arr_smallint_col array<array<smallint>>,
arr_arr_int_col array<array<int>>,
arr_arr_bigint_col array<array<bigint>>,
arr_arr_largeint_col array<array<largeint>>,
arr_arr_float_col array<array<float>>,
arr_arr_double_col array<array<double>>,
arr_arr_decimal1_col array<array<decimal(10, 5)>>,
arr_arr_decimal2_col array<array<decimal(30, 10)>>,
arr_arr_date_col array<array<date>>,
arr_arr_datetime_col array<array<datetime(3)>>,
arr_arr_char_col array<array<char(10)>>,
arr_arr_varchar_col array<array<varchar(10)>>,
arr_arr_string_col array<array<string>>
)
DUPLICATE KEY(`int_col`)
DISTRIBUTED BY HASH(`int_col`) BUCKETS 3
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """insert into arr_nesting_types_test values (1, array(array(true)), array(array(1)), array(array(1)), array(array(1)), array(array(1)), array(array(1)), array(array(1.0)), array(array(1.0)), array(array(1.0)), array(array(1.0)), array(array('2021-01-01')), array(array('2021-01-01 00:00:00.000')), array(array('a')), array(array('a')), array(array('a')));"""
sql """insert into arr_nesting_types_test values (2, array(array(true),array(true)), array(array(1),array(1)), array(array(1),array(1)), array(array(1),array(1)), array(array(1),array(1)), array(array(1),array(1)), array(array(1.0),array(1.0)), array(array(1.0),array(1.0)), array(array(1.0),array(1.0)), array(array(1.0),array(1.0)), array(array('2021-01-01'),array('2021-01-01')), array(array('2021-01-01 00:00:00.000'),array('2021-01-01 00:00:00.000')), array(array('a'),array('a')), array(array('a'),array('a')), array(array('a'),array('a')));"""
sql """insert into arr_nesting_types_test values (3, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);"""
sql """drop catalog if exists doris_all_type_test """
sql """ CREATE CATALOG doris_all_type_test PROPERTIES (
"user" = "${jdbcUser}",
"type" = "jdbc",
"password" = "${jdbcPassword}",
"jdbc_url" = "${jdbcUrl}",
"driver_url" = "${driver_url}",
"driver_class" = "com.mysql.cj.jdbc.Driver"
)
"""
qt_desc_all_types_nullable """desc doris_all_type_test.test_doris_all_types_select.all_types_nullable;"""
qt_select_all_types_nullable """select * except(float_col) from doris_all_type_test.test_doris_all_types_select.all_types_nullable order by 1;"""
qt_desc_all_types_non_nullable """desc doris_all_type_test.test_doris_all_types_select.all_types_non_nullable;"""
qt_select_all_types_non_nullable """select * except(float_col) from doris_all_type_test.test_doris_all_types_select.all_types_non_nullable order by 1;"""
qt_desc_bitmap_hll """desc doris_all_type_test.test_doris_all_types_select.t_hll_bitmap;"""
qt_select_bitmap_hll """select k, bitmap_union_count(bitmap_c), hll_union_agg(hll_c) from doris_all_type_test.test_doris_all_types_select.t_hll_bitmap group by k order by 1;"""
qt_desc_arr_types_test """desc doris_all_type_test.test_doris_all_types_select.arr_types_test;"""
qt_select_arr_types_test """select * from doris_all_type_test.test_doris_all_types_select.arr_types_test order by 1;"""
qt_desc_arr_nesting_types_test """desc doris_all_type_test.test_doris_all_types_select.arr_nesting_types_test;"""
qt_select_arr_nesting_types_test """select * from doris_all_type_test.test_doris_all_types_select.arr_nesting_types_test order by 1;"""
sql """drop database if exists test_doris_all_types_select;"""
sql """drop catalog if exists doris_all_type_test """
}

View File

@ -0,0 +1,52 @@
// 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_mysql_all_types_select", "p0,external,mysql,external_docker,external_docker_mysql") {
String enabled = context.config.otherConfigs.get("enableJdbcTest")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"
if (enabled != null && enabled.equalsIgnoreCase("true")) {
String mysql_port = context.config.otherConfigs.get("mysql_57_port");
sql """drop catalog if exists mysql_all_type_test """
sql """create catalog if not exists mysql_all_type_test properties(
"type"="jdbc",
"user"="root",
"password"="123456",
"jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}/doris_test?useSSL=false",
"driver_url" = "${driver_url}",
"driver_class" = "com.mysql.cj.jdbc.Driver"
);"""
sql """use mysql_all_type_test.doris_test"""
qt_desc_all_types_null """desc all_types_nullable;"""
qt_select_all_types_null """select * from all_types_nullable order by 1;"""
qt_desc_all_types_non_null """desc all_types_non_nullable;"""
qt_select_all_types_non_null """select * from all_types_non_nullable order by 1;"""
qt_select_varchar """select * from t_varchar order by 1;"""
qt_select_char """select * from t_char order by 1;"""
qt_select_all_types_multi_block """select count(`int`),count(`varchar`) from all_types_multi_block;"""
sql """drop catalog if exists mysql_all_type_test """
}
}

View File

@ -0,0 +1,48 @@
// 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_mysql_all_types_tvf", "p0,external,mysql,external_docker,external_docker_mysql") {
String enabled = context.config.otherConfigs.get("enableJdbcTest")
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
String s3_endpoint = getS3Endpoint()
String bucket = getS3BucketName()
String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-j-8.3.0.jar"
if (enabled != null && enabled.equalsIgnoreCase("true")) {
String mysql_port = context.config.otherConfigs.get("mysql_57_port");
sql """drop catalog if exists mysql_all_type_tvf_test """
sql """create catalog if not exists mysql_all_type_tvf_test properties(
"type"="jdbc",
"user"="root",
"password"="123456",
"jdbc_url" = "jdbc:mysql://${externalEnvIp}:${mysql_port}/doris_test?useSSL=false",
"driver_url" = "${driver_url}",
"driver_class" = "com.mysql.cj.jdbc.Driver"
);"""
qt_desc_tvf_all_types_null """desc function query('catalog' = 'mysql_all_type_tvf_test', 'query' = 'select * from all_types_nullable')"""
qt_tvf_null_all_types_null """select * from query('catalog' = 'mysql_all_type_tvf_test', 'query' = 'select * from all_types_nullable') order by 1;"""
qt_desc_tvf_all_types_non_null """desc function query('catalog' = 'mysql_all_type_tvf_test', 'query' = 'select * from all_types_non_nullable')"""
qt_tvf_null_all_types_non_null """select * from query('catalog' = 'mysql_all_type_tvf_test', 'query' = 'select * from all_types_non_nullable') order by 1;"""
sql """drop catalog if exists mysql_all_type_tvf_test """
}
}