-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Implemented JDBC for IoTDB based on tables #14656
base: master
Are you sure you want to change the base?
Conversation
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.
Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.
sync remote and local code
jdbc activeByDefault get-jar-with-dependencies
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
Outdated
Show resolved
Hide resolved
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBConnection.java
Show resolved
Hide resolved
iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBAbstractDatabaseMetadata.java
Outdated
Show resolved
Hide resolved
public static final Logger logger = org.slf4j.LoggerFactory.getLogger(IoTDBStatement.class); | ||
|
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.
what's this used for? You should define the logger for each class
LOGGER.info( | ||
"GetTables:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, types:{}", | ||
catalog, | ||
schemaPattern, | ||
tableNamePattern, | ||
types); |
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.
LOGGER.info( | |
"GetTables:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, types:{}", | |
catalog, | |
schemaPattern, | |
tableNamePattern, | |
types); |
|
||
@Override | ||
public ResultSet getTables( | ||
String catalog, String schemaPattern, String tableNamePattern, String[] types) |
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.
schemaPattern
and tableNamePattern
are botn pattern, you should use like to do that filter. And the interface definition also tells the order of the result, you should order by database, table_name.
you can use information_schema.tables to do that. https://timechor.feishu.cn/docx/Mqi9dCcu2oXLo4xxZVbcn8SKnKh
|
||
@Override | ||
public ResultSet getColumns( | ||
String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) |
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.
use information_schema.columns
to do that.
LOGGER.info( | ||
"GetColumns:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, columnNamePattern:{}", | ||
catalog, | ||
schemaPattern, | ||
tableNamePattern, | ||
columnNamePattern); |
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.
LOGGER.info( | |
"GetColumns:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, columnNamePattern:{}", | |
catalog, | |
schemaPattern, | |
tableNamePattern, | |
columnNamePattern); |
} | ||
|
||
static { | ||
String[] allIotdbSQLKeywords = { |
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.
keywords of table and tree model are different, you can find keywords of table model in https://timechor.feishu.cn/docx/U5OHdYQs1oR0hVxvy5Ucw0KUnBf
ResultSet resultSet = null; | ||
Statement statement = null; | ||
String result = ""; | ||
try { | ||
statement = connection.createStatement(); | ||
StringBuilder str = new StringBuilder(""); | ||
resultSet = statement.executeQuery(SHOW_FUNCTIONS); | ||
List<String> listFunction = Arrays.asList("MAX_TIME", "MIN_TIME", "TIME_DIFFERENCE", "NOW"); | ||
while (resultSet.next()) { | ||
if (listFunction.contains(resultSet.getString(1))) { | ||
continue; | ||
} | ||
str.append(resultSet.getString(1)).append(","); | ||
} | ||
result = str.toString(); | ||
if (!result.isEmpty()) { | ||
result = result.substring(0, result.length() - 1); | ||
} | ||
} catch (Exception e) { | ||
LOGGER.error("Get numeric functions error: {}", e.getMessage()); | ||
} finally { | ||
close(resultSet, statement); | ||
} | ||
return result; | ||
} |
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.
not right
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.
LGTM
Primary Changes
Key Results