This is an automated email from the ASF dual-hosted git repository.
critas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d245edce685 Fix NPE in table model export when -q is not specified
(#17462)
d245edce685 is described below
commit d245edce685bede38f067afb91454fc675a03bd5
Author: CritasWang <[email protected]>
AuthorDate: Mon Apr 13 14:17:15 2026 +0800
Fix NPE in table model export when -q is not specified (#17462)
When using export-data with table model (sql_dialect=table) and only
specifying -db without -q, queryCommand is null. The original condition
`sqlDialectTree && queryCommand == null` only handled the tree model
case, causing the else branch to call `queryCommand.trim().split(";")`
which throws NullPointerException.
Restructure the branch logic to check `queryCommand == null` first:
- Tree model + no query: interactive SQL input (unchanged)
- Table model + no query: call exportBySql(null, 0) to auto-generate
"select * from <table>" for all tables, which also correctly applies
start_time/end_time filters
- Query provided: split by semicolon for multi-statement support
(unchanged)
---
.../org/apache/iotdb/tool/data/ExportData.java | 28 ++++++++++++----------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git
a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportData.java
b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportData.java
index 9f52c6834be..322f10e059b 100644
--- a/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportData.java
+++ b/iotdb-client/cli/src/main/java/org/apache/iotdb/tool/data/ExportData.java
@@ -224,18 +224,22 @@ public class ExportData extends AbstractDataTool {
exportData = new ExportDataTable();
exportData.init();
}
- if (sqlDialectTree && queryCommand == null) {
- LineReader lineReader =
- JlineUtils.getLineReader(
- new CliContext(System.in, System.out, System.err,
ExitType.EXCEPTION),
- username,
- host,
- port);
- String sql = lineReader.readLine(Constants.EXPORT_CLI_PREFIX + ">
please input query: ");
- ioTPrinter.println(sql);
- String[] values = sql.trim().split(";");
- for (int i = 0; i < values.length; i++) {
- exportData.exportBySql(values[i], i);
+ if (queryCommand == null) {
+ if (sqlDialectTree) {
+ LineReader lineReader =
+ JlineUtils.getLineReader(
+ new CliContext(System.in, System.out, System.err,
ExitType.EXCEPTION),
+ username,
+ host,
+ port);
+ String sql = lineReader.readLine(Constants.EXPORT_CLI_PREFIX + ">
please input query: ");
+ ioTPrinter.println(sql);
+ String[] values = sql.trim().split(";");
+ for (int i = 0; i < values.length; i++) {
+ exportData.exportBySql(values[i], i);
+ }
+ } else {
+ exportData.exportBySql(null, 0);
}
} else {
String[] values = queryCommand.trim().split(";");