Skip to content

fix hive column type support #1199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/sqlflowserver/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ func TestEnd2EndHive(t *testing.T) {
t.Run("TestShowDatabases", CaseShowDatabases)
t.Run("TestSelect", CaseSelect)
t.Run("TestTrainSQL", CaseTrainSQL)
t.Run("CaseTrainRegression", CaseTrainRegression)
t.Run("CaseTrainCustomModel", CaseTrainCustomModel)
t.Run("CaseTrainDeepWideModel", CaseTrainDeepWideModel)
t.Run("CaseTrainXGBoostRegression", CaseTrainXGBoostRegression)
Expand Down
9 changes: 6 additions & 3 deletions pkg/sql/feature_derivation.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ func newRowValue(columnTypeList []*sql.ColumnType) ([]interface{}, error) {
rowData := make([]interface{}, len(columnTypeList))
for idx, ct := range columnTypeList {
typeName := ct.DatabaseTypeName()
// NOTE(typhoonzero): Hive uses typenames like "XXX_TYPE"
if strings.HasSuffix(typeName, "_TYPE") {
typeName = strings.Replace(typeName, "_TYPE", "", 1)
}
switch typeName {
case "VARCHAR", "TEXT":
rowData[idx] = new(string)
// XXX_TYPE is the type name used by Hive
case "INT", "INT_TYPE":
case "INT":
rowData[idx] = new(int32)
case "BIGINT", "DECIMAL":
rowData[idx] = new(int64)
case "FLOAT", "FLOAT_TYPE":
case "FLOAT":
rowData[idx] = new(float32)
case "DOUBLE":
rowData[idx] = new(float64)
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/testdata/housing_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ CREATE TABLE housing.train (
f7 float,
f8 float,
f9 int,
f10 int,
f10 bigint,
f11 float,
f12 float,
f13 float,
target float);
target double);
INSERT INTO housing.train VALUES
(1.232470,0.000000,8.140000,0.000000,0.538000,6.142000,91.700000,3.976900,4.000000,307.000000,21.000000,396.900000,18.720000,15.200000),
(0.021770,82.500000,2.030000,0.000000,0.415000,7.610000,15.700000,6.270000,2.000000,348.000000,14.700000,395.380000,3.110000,42.300000),
Expand Down Expand Up @@ -449,11 +449,11 @@ CREATE TABLE housing.test (
f7 float,
f8 float,
f9 int,
f10 int,
f10 bigint,
f11 float,
f12 float,
f13 float,
target float);
target double);
INSERT INTO housing.test VALUES
(18.084600,0.000000,18.100000,0.000000,0.679000,6.434000,100.000000,1.834700,24.000000,666.000000,20.200000,27.250000,29.050000,7.200000),
(0.123290,0.000000,10.010000,0.000000,0.547000,5.913000,92.900000,2.353400,6.000000,432.000000,17.800000,394.950000,16.210000,18.800000),
Expand Down