dremio singlestore arp 扩展
此插件来自singlestore官方的,基于了dremio 23.1 版本开发
conf 配置类
@SourceType(value = "SINGLESTOREARP", label = "SingleStore", uiConfig = "singlestore-layout.json", externalQuerySupported = true)
public class SingleStoreConf extends AbstractArpConf<SingleStoreConf> {
private static final String ARP_FILENAME = "arp/implementation/singlestore-arp.yaml";
private static final ArpDialect ARP_DIALECT =
AbstractArpConf.loadArpFile(ARP_FILENAME, (ArpDialect::new));
private static final String DRIVER = "com.singlestore.jdbc.Driver";
@NotBlank
@Tag(1)
@DisplayMetadata(label = "Host")
public String host;
@Tag(2)
@DisplayMetadata(label = "Port")
public int port = 3306;
@NotBlank
@Tag(3)
@DisplayMetadata(label = "Database")
public String database;
@NotBlank
@Tag(4)
@DisplayMetadata(label = "Username")
public String user;
@NotBlank
@Tag(5)
@Secret
@DisplayMetadata(label = "Password")
public String password;
@Tag(6)
@DisplayMetadata(label = "Use SSL")
public boolean useSsl;
@Tag(7)
@DisplayMetadata(label = "Server Certificate")
public String serverSslCert;
@Tag(8)
@DisplayMetadata(label = "Record fetch size")
@NotMetadataImpacting
public int fetchSize = 200;
@Tag(9)
@DisplayMetadata(label = "Maximum idle connections")
@NotMetadataImpacting
public int maxIdleConns = 8;
@Tag(10)
@DisplayMetadata(label = "Connection idle time (s)")
@NotMetadataImpacting
public int idleTimeSec = 60;
@Tag(11)
public List<Property> propertyList;
@VisibleForTesting
public String toJdbcConnectionString() {
String url = String.format("jdbc:singlestore://%s:%s", host, port);
boolean userProvided = false;
if (database != null && !database.equals("")) {
url += String.format("/%s", database);
}
if (user != null && !user.equals("")) {
url += String.format("?user=%s", user);
userProvided = true;
}
if (password != null && !password.equals("")) {
url += String.format("%spassword=%s", userProvided ? "&" : "?", password);
}
if (useSsl) {
url += "&useSsl=true";
}
if (serverSslCert != null && !serverSslCert.equals("")) {
url += String.format("&serverSslCert=%s", serverSslCert);
}
if (this.propertyList != null) {
for (Property p : this.propertyList) {
url += String.format("&%s=%s", p.name, p.value);
}
}
return url;
}
@Override
@VisibleForTesting
public JdbcPluginConfig buildPluginConfig(
JdbcPluginConfig.Builder configBuilder,
CredentialsService credentialsService,
OptionManager optionManager
) {
return configBuilder.withDialect(getDialect())
.withDialect(getDialect())
.withFetchSize(fetchSize)
.withDatasourceFactory(this::newDataSource)
.clearHiddenSchemas()
.addHiddenSchema("SYSTEM")
.build();
}
private CloseableDataSource newDataSource() {
return DataSources.newGenericConnectionPoolDataSource(DRIVER,
toJdbcConnectionString(), user, password, null, DataSources.CommitMode.DRIVER_SPECIFIED_COMMIT_MODE,
maxIdleConns, idleTimeSec);
}
@Override
public ArpDialect getDialect() {
return ARP_DIALECT;
}
@VisibleForTesting
public static ArpDialect getDialectSingleton() {
return ARP_DIALECT;
}
}
arp 配置
核心是类型映射,主要在src/main/resources/arp/implementation/singlestore-arp.yaml
主要禁用了catalog ,以及schema,其他部分可以参考实际内容
syntax:
# Manually Configured Syntax Section.
identifier_quote: '`'
identifier_length_limit: 128
allows_boolean_literal: true
map_boolean_literal_to_bit: false
supports_catalogs: false
supports_schemas: false
说明
jdbc 驱动需要自己下载放到dremio 的classpath 路径下,通过singlestore 官方的dremio arp 扩展可以了解一些开发,实际上singlestore 的jdbc
是基于了mariadb-connector-j
参考资料
https://github.com/memsql/dremio-singlestore
https://github.com/memsql/S2-JDBC-Connector
https://github.com/mariadb-corporation/mariadb-connector-j