Skip to content
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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

LJW21-02
Copy link

@LJW21-02 LJW21-02 commented Jan 9, 2025

Primary Changes

  • modified codes in iotdb-client/jdbc
  • increased IoTDBAbstractDatabaseMetadata, IoTDBDatabaseMetadata, IoTDBTableDatabaseMetadata
  • modified pom.xml

Key Results

  • able to connect both tree-model IoTDB and table-model IoTDB in DBeaver
    Screenshot 2025-02-18 at 9 32 44 AM
  • able to view the data in tables
    Screenshot 2025-02-18 at 9 36 06 AM

Copy link

@github-actions github-actions bot left a 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.

iotdb-client/jdbc/pom.xml Outdated Show resolved Hide resolved
Comment on lines 52 to 53
public static final Logger logger = org.slf4j.LoggerFactory.getLogger(IoTDBStatement.class);

Copy link
Contributor

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

Comment on lines 72 to 77
LOGGER.info(
"GetTables:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, types:{}",
catalog,
schemaPattern,
tableNamePattern,
types);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOGGER.info(
"GetTables:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, types:{}",
catalog,
schemaPattern,
tableNamePattern,
types);


@Override
public ResultSet getTables(
String catalog, String schemaPattern, String tableNamePattern, String[] types)
Copy link
Contributor

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)
Copy link
Contributor

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.

Comment on lines 159 to 164
LOGGER.info(
"GetColumns:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, columnNamePattern:{}",
catalog,
schemaPattern,
tableNamePattern,
columnNamePattern);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOGGER.info(
"GetColumns:: catalog:{}, schemaPattern:{}, tableNamePattern:{}, columnNamePattern:{}",
catalog,
schemaPattern,
tableNamePattern,
columnNamePattern);

}

static {
String[] allIotdbSQLKeywords = {
Copy link
Contributor

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

Comment on lines 849 to 873
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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not right

Copy link
Collaborator

@CritasWang CritasWang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants