-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Feature][Connector-V2] Kylin source connector #3116
Changes from all commits
cefb02d
0b34bed
4d40088
42081de
5d1511c
e07dafc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.kylin; | ||
|
||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; | ||
|
||
public class KylinDialect implements JdbcDialect { | ||
@Override | ||
public String dialectName() { | ||
return "Kylin"; | ||
} | ||
|
||
@Override | ||
public JdbcRowConverter getRowConverter() { | ||
return new KylinJdbcRowConverter(); | ||
} | ||
|
||
@Override | ||
public JdbcDialectTypeMapper getJdbcDialectTypeMapper() { | ||
return new KylinTypeMapper(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.kylin; | ||
|
||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
@AutoService(JdbcDialectFactory.class) | ||
public class KylinDialectFactory implements JdbcDialectFactory { | ||
@Override | ||
public boolean acceptsURL(String url) { | ||
return url.startsWith("jdbc:kylin:"); | ||
} | ||
|
||
@Override | ||
public JdbcDialect create() { | ||
return new KylinDialect(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.kylin; | ||
|
||
import org.apache.seatunnel.api.table.type.SeaTunnelRow; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelRowType; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.AbstractJdbcRowConverter; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.ResultSetMetaData; | ||
import java.sql.SQLException; | ||
|
||
public class KylinJdbcRowConverter extends AbstractJdbcRowConverter { | ||
@Override | ||
public String converterName() { | ||
return "Kylin"; | ||
} | ||
|
||
@Override | ||
public SeaTunnelRow toInternal(ResultSet rs, ResultSetMetaData metaData, SeaTunnelRowType typeInfo) throws SQLException { | ||
return super.toInternal(rs, metaData, typeInfo); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.kylin; | ||
|
||
import org.apache.seatunnel.api.table.type.BasicType; | ||
import org.apache.seatunnel.api.table.type.DecimalType; | ||
import org.apache.seatunnel.api.table.type.LocalTimeType; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelDataType; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.sql.ResultSetMetaData; | ||
import java.sql.SQLException; | ||
|
||
public class KylinTypeMapper implements JdbcDialectTypeMapper { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(KylinTypeMapper.class); | ||
|
||
// ============================data types===================== | ||
|
||
private static final String KYLIN_UNKNOWN = "UNKNOWN"; | ||
private static final String KYLIN_BOOLEAN = "BOOLEAN"; | ||
|
||
// -------------------------number---------------------------- | ||
private static final String KYLIN_TINYINT = "TINYINT"; | ||
private static final String KYLIN_SMALLINT = "SMALLINT"; | ||
private static final String KYLIN_INT = "INT"; | ||
private static final String KYLIN_BIGINT = "BIGINT"; | ||
private static final String KYLIN_DECIMAL = "DECIMAL"; | ||
private static final String KYLIN_FLOAT = "FLOAT"; | ||
private static final String KYLIN_DOUBLE = "DOUBLE"; | ||
|
||
// -------------------------string---------------------------- | ||
private static final String KYLIN_CHAR = "CHAR"; | ||
private static final String KYLIN_VARCHAR = "VARCHAR"; | ||
private static final String KYLIN_STRING = "STRING"; | ||
|
||
// ------------------------------time------------------------- | ||
private static final String KYLIN_DATE = "DATE"; | ||
private static final String KYLIN_TIME = "TIME"; | ||
private static final String KYLIN_TIMESTAMP = "TIMESTAMP"; | ||
|
||
@SuppressWarnings("checkstyle:MagicNumber") | ||
@Override | ||
public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex) throws SQLException { | ||
String kylinType = metadata.getColumnTypeName(colIndex).toUpperCase(); | ||
int precision = metadata.getPrecision(colIndex); | ||
int scale = metadata.getScale(colIndex); | ||
switch (kylinType) { | ||
case KYLIN_BOOLEAN: | ||
return BasicType.BOOLEAN_TYPE; | ||
case KYLIN_TINYINT: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
thinks your good advice,i have fixed it in new commit |
||
case KYLIN_SMALLINT: | ||
return BasicType.SHORT_TYPE; | ||
case KYLIN_INT: | ||
return BasicType.INT_TYPE; | ||
case KYLIN_BIGINT: | ||
return BasicType.LONG_TYPE; | ||
case KYLIN_DECIMAL: | ||
return new DecimalType(precision, scale); | ||
case KYLIN_FLOAT: | ||
return BasicType.FLOAT_TYPE; | ||
case KYLIN_DOUBLE: | ||
return BasicType.DOUBLE_TYPE; | ||
case KYLIN_CHAR: | ||
case KYLIN_VARCHAR: | ||
case KYLIN_STRING: | ||
return BasicType.STRING_TYPE; | ||
case KYLIN_DATE: | ||
return LocalTimeType.LOCAL_DATE_TYPE; | ||
case KYLIN_TIME: | ||
return LocalTimeType.LOCAL_TIME_TYPE; | ||
case KYLIN_TIMESTAMP: | ||
return LocalTimeType.LOCAL_DATE_TIME_TYPE; | ||
//Doesn't support yet | ||
case KYLIN_UNKNOWN: | ||
default: | ||
final String jdbcColumnName = metadata.getColumnName(colIndex); | ||
throw new UnsupportedOperationException( | ||
String.format( | ||
"Doesn't support KYLIN type '%s' on column '%s' yet.", | ||
kylinType, jdbcColumnName)); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add
changed log
reference https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/connector-v2/source/Redis.md#next-version