Skip to content

Fix NPE in table model export when -q is not specified#17462

Merged
CritasWang merged 1 commit intomasterfrom
fix_export
Apr 13, 2026
Merged

Fix NPE in table model export when -q is not specified#17462
CritasWang merged 1 commit intomasterfrom
fix_export

Conversation

@CritasWang
Copy link
Copy Markdown
Collaborator

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 " for all tables, which also correctly applies start_time/end_time filters
  • Query provided: split by semicolon for multi-statement support (unchanged)

  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)
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.83%. Comparing base (1c1cbca) to head (d6b4fa5).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...in/java/org/apache/iotdb/tool/data/ExportData.java 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #17462   +/-   ##
=========================================
  Coverage     39.82%   39.83%           
  Complexity      312      312           
=========================================
  Files          5135     5135           
  Lines        347073   347075    +2     
  Branches      44220    44221    +1     
=========================================
+ Hits         138221   138252   +31     
+ Misses       208852   208823   -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CritasWang CritasWang merged commit d245edc into master Apr 13, 2026
30 checks passed
@CritasWang CritasWang deleted the fix_export branch April 13, 2026 06:17
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.

2 participants