-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#3371] feat(flink-connector): support basic table operation
- Loading branch information
Showing
7 changed files
with
455 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
flink-connector/src/main/java/com/datastrato/gravitino/flink/connector/utils/TypeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.flink.connector.utils; | ||
|
||
import com.datastrato.gravitino.rel.types.Type; | ||
import com.datastrato.gravitino.rel.types.Types; | ||
import org.apache.flink.table.api.DataTypes; | ||
import org.apache.flink.table.types.DataType; | ||
import org.apache.flink.table.types.logical.LogicalType; | ||
|
||
public class TypeUtils { | ||
|
||
private TypeUtils() {} | ||
|
||
public static Type toGravitinoType(LogicalType logicalType) { | ||
switch (logicalType.getTypeRoot()) { | ||
case VARCHAR: | ||
return Types.StringType.get(); | ||
case DOUBLE: | ||
return Types.DoubleType.get(); | ||
default: | ||
throw new UnsupportedOperationException( | ||
"Not support type: " + logicalType.asSummaryString()); | ||
} | ||
} | ||
|
||
public static DataType toFlinkType(Type gravitinoType) { | ||
if (gravitinoType instanceof Types.DoubleType) { | ||
return DataTypes.DOUBLE(); | ||
} else if (gravitinoType instanceof Types.StringType) { | ||
return DataTypes.STRING(); | ||
} | ||
throw new UnsupportedOperationException("Not support " + gravitinoType.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.