mchades commented on code in PR #5182:
URL: https://github.com/apache/gravitino/pull/5182#discussion_r1809786136
##########
catalogs/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/converter/OceanBaseTypeConverter.java:
##########
@@ -19,22 +19,132 @@
package org.apache.gravitino.catalog.oceanbase.converter;
import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
-import org.apache.gravitino.exceptions.GravitinoRuntimeException;
import org.apache.gravitino.rel.types.Type;
+import org.apache.gravitino.rel.types.Types;
/** Type converter for OceanBase. */
public class OceanBaseTypeConverter extends JdbcTypeConverter {
- // More data types will be added.
static final String TINYINT = "tinyint";
+ static final String TINYINT_UNSIGNED = "tinyint unsigned";
+ static final String SMALLINT = "smallint";
+ static final String SMALLINT_UNSIGNED = "smallint unsigned";
+ static final String INT = "int";
+ static final String INT_UNSIGNED = "int unsigned";
+ static final String BIGINT = "bigint";
+ static final String BIGINT_UNSIGNED = "bigint unsigned";
+ static final String FLOAT = "float";
+ static final String DOUBLE = "double";
+ static final String DECIMAL = "decimal";
+ static final String NUMBER = "number";
+ static final String NUMERIC = "numeric";
+ static final String CHAR = "char";
+ static final String BINARY = "binary";
+ static final String DATETIME = "datetime";
+ static final String JSON = "json";
@Override
public Type toGravitino(JdbcTypeBean typeBean) {
- throw new GravitinoRuntimeException("Not implemented yet.");
+ switch (typeBean.getTypeName().toLowerCase()) {
+ case TINYINT:
+ return Types.ByteType.get();
+ case TINYINT_UNSIGNED:
+ return Types.ByteType.unsigned();
+ case SMALLINT:
+ return Types.ShortType.get();
+ case SMALLINT_UNSIGNED:
+ return Types.ShortType.unsigned();
+ case INT:
+ return Types.IntegerType.get();
+ case INT_UNSIGNED:
+ return Types.IntegerType.unsigned();
+ case BIGINT:
+ return Types.LongType.get();
+ case BIGINT_UNSIGNED:
+ return Types.LongType.unsigned();
+ case FLOAT:
+ return Types.FloatType.get();
+ case DOUBLE:
+ return Types.DoubleType.get();
+ case DATE:
+ return Types.DateType.get();
+ case TIME:
+ return Types.TimeType.get();
+ case TIMESTAMP:
+ return Types.TimestampType.withTimeZone();
+ case DATETIME:
+ return Types.TimestampType.withoutTimeZone();
+ case NUMBER:
+ case NUMERIC:
+ case DECIMAL:
+ return Types.DecimalType.of(
+ Integer.parseInt(typeBean.getColumnSize()),
Integer.parseInt(typeBean.getScale()));
+ case VARCHAR:
+ return
Types.VarCharType.of(Integer.parseInt(typeBean.getColumnSize()));
+ case CHAR:
+ return
Types.FixedCharType.of(Integer.parseInt(typeBean.getColumnSize()));
+ case JSON:
Review Comment:
suggest removing this, we can add this after Gravitino supports `JSON` data
type
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]