Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
c82ab13
Add Object Type
JackieTien97 Jul 11, 2025
5981bba
fix ttl deletion
shuwenwei Jul 12, 2025
f5353fa
Limit the return size for client instead of always using fetchSize
JackieTien97 Jul 12, 2025
62cca07
Add compress for geo_penetrate
JackieTien97 Jul 13, 2025
50291a6
Fix object table split to multi regions (#15927)
HTHou Jul 14, 2025
6ed7098
[To object_type] Fix wrong object value inserted (#15928)
HTHou Jul 14, 2025
38bd51b
fix ttl deletion
shuwenwei Jul 14, 2025
9e0d8c3
fix ttl deletion
shuwenwei Jul 14, 2025
cbf0927
fix multi measurement name
HTHou Jul 15, 2025
1f5e9ec
cpp client datatype OBJECT (#16094)
hongzhi-gao Aug 5, 2025
ae5d7b8
make offset of read_object take effective
JackieTien97 Aug 11, 2025
ca06bc4
Print file name while encountering error
JackieTien97 Aug 15, 2025
e5e520d
Print file name while encountering error
JackieTien97 Aug 15, 2025
1254bdf
Add object type file metric (#16257)
HTHou Aug 26, 2025
f9a9bc2
modify the log of removing object file
shuwenwei Aug 27, 2025
42d7638
Hide password related parameters in show configuration result (#16675)
shuwenwei Oct 30, 2025
4ede61c
Avoid throwing AuthException to the state machine (#16677)
shuwenwei Oct 30, 2025
c8e322c
If the client input uses "-usessl", then force interactive input of t…
hongzhi-gao Oct 31, 2025
367bb50
Fix process logic of empty TsBlock in InputLayer of TransformOperator…
Wei-hao-Li Oct 31, 2025
36bb2b1
Bump logback version to 1.3.16 (#16671)
HTHou Oct 31, 2025
0fae41e
Use the correct value in showConfiguration to override the value read…
shuwenwei Oct 31, 2025
cc8a718
Fixed the bug that the attribute update container may add extra calcu…
Caideyipi Oct 31, 2025
65ec0e2
Add more optimizers for union (#16689)
Wei-hao-Li Nov 3, 2025
eae73aa
SeriesScanUtil throws exception when using filters that could not mat…
shuwenwei Nov 4, 2025
eab51a6
Add object type in CompatibleResolver
JackieTien97 Nov 4, 2025
6ea56d9
Support In UDF Record
JackieTien97 Nov 5, 2025
25082b2
disable object type in UDTF
JackieTien97 Nov 5, 2025
391429b
[To force_ci/object_type] Support insert object by sql & add IT (#16683)
HTHou Nov 6, 2025
0fc8e17
Fix wrong push limit down to AggTableScanNode (#16696)
JackieTien97 Nov 4, 2025
4dbb3c6
More robust IoTDBRegionReconstructForIoTV1IT (#16697)
CRZbulabula Nov 4, 2025
1bb15b2
Implemented the alter encoding compression function for tree model (#…
Caideyipi Nov 6, 2025
0971b8f
Support SSL-related parameters and interactive password input in expo…
LJW21-02 Nov 7, 2025
0e15626
implement the intersect (distinct | all ) for table model (#16700)
alpass163 Nov 7, 2025
96d4eae
Fix the error message of ConfigExecution (#16680)
shuwenwei Nov 7, 2025
5d9baf5
Fixed the null error message of fetch schema failed when the regions …
Caideyipi Nov 7, 2025
d0de0a6
Pipe: Fixed the NPE of commit interval (#16714)
Caideyipi Nov 10, 2025
ba7a7a6
Follow fix for encoding & compressor (#16712)
Caideyipi Nov 10, 2025
0657671
Avoid unnecessary ssl error log caused by jdk bug (#16709)
HTHou Nov 10, 2025
cbe5765
Active Load: Ignore java.io.UncheckedIOException exceptions thrown du…
luoluoyuyu Nov 10, 2025
3a8d6d5
Delete the tsfile and related attachments When only one table and dat…
zerolbsony Nov 10, 2025
602d465
Fixed the potential non-consistency caused by initialize of DataNodeT…
Caideyipi Nov 10, 2025
ce054e8
Optimize the configuration logic of dn_thrift_max_frame_size (#16724)
HTHou Nov 10, 2025
6f47cca
Changed the SQL of AlterEncodingCompressor statement & banned the "ro…
Caideyipi Nov 10, 2025
26b5ae3
chore!: Bind real config address for Thrift and Raft services (#16717)
CritasWang Nov 11, 2025
a3807d2
Make ErrMsg more readable when the predicate has too many conjunction…
Wei-hao-Li Nov 11, 2025
d24cdda
Pipe: Fix unhandled timeout exceptions in Thrift Client (#16727)
luoluoyuyu Nov 11, 2025
15f39d4
Fixed the procedure has_more_state bug & Fixed the IT for encoding & …
Caideyipi Nov 11, 2025
8a3dbcb
Optimized the lock for encoding & compressor's invalidate cache (#16733)
Caideyipi Nov 11, 2025
25d5ba5
Pipe: support path exclusion under tree model (#16632)
VGalaxies Nov 12, 2025
f19824d
Change the privilege of showVersionStatement #16736
shuwenwei Nov 12, 2025
ff6f7a2
[AINode] Package AINode via PyInstaller (#16707)
CRZbulabula Nov 12, 2025
4e1df94
Support the JDBC client to prevent SQL injection (#16734)
Young-Leo Nov 12, 2025
a1fe410
Fix that a deletion test may fail due to inconsistency caused by lead…
jt2594838 Nov 12, 2025
d712ffc
Fixed the NPE caused by concurrent "check for createTimeSeries" and d…
Caideyipi Nov 12, 2025
92878f4
Pipe: Optimized the default behavior in meta sync for retries to wait…
Caideyipi Nov 12, 2025
197c4f1
Adjust the exception message cause by the WHERE clause, which uses a …
zerolbsony Nov 13, 2025
401c5e9
Pipe: Trimmed some of the pipe logs (#16747)
Caideyipi Nov 13, 2025
43c0320
Active Load: Fixes errors caused by Load copying resource files. (#16…
luoluoyuyu Nov 14, 2025
8fe93f2
Pipe: Modify the Pipe configuration item log name to be consistent wi…
luoluoyuyu Nov 14, 2025
b396766
feat: encode load attributes in active load directories (#16722)
luoluoyuyu Nov 14, 2025
3a6c3bb
[AINode] Enable AINode start as background (-d) (#16762)
CRZbulabula Nov 15, 2025
71976f5
fix (#16702)
Caideyipi Nov 17, 2025
104bcf1
reduce error log when compaction service is stopped & fix bugs (#16756)
shuwenwei Nov 17, 2025
dfda7a0
[AINode] Update AINodeClient for DataNode to borrow (#16647)
Alchuang22-dev Nov 17, 2025
08c0eec
[AINode] Fix bug that AINode cannot compile in Windows (#16767)
CRZbulabula Nov 17, 2025
2078b4f
fix (#16773)
Caideyipi Nov 18, 2025
c110ab1
Load: Fixed the bug that mods is not deleted in load tsFile when ther…
Caideyipi Nov 18, 2025
81b6d59
[AINode] Fix bug of sundial and forecast udf (#16768)
yunbow30944 Nov 19, 2025
842c4a5
Fixed the bugs related to device auto-create alignment ignorance (#16…
Caideyipi Nov 20, 2025
fe49c5e
Load: Active Load supports ModV2 (#16769)
luoluoyuyu Nov 20, 2025
769f103
Load: Fixed the issue of TSFile parent directory being null and TSFil…
luoluoyuyu Nov 20, 2025
e72ee9a
Load: Fixed parameter passing error in MoveFile function (#16748)
luoluoyuyu Nov 20, 2025
40355e3
Refine CN consensus layer API for procedure robustness (#16303)
Pengzna Nov 20, 2025
b7e1c02
Pipe: improved the memory calculation for tablets (#16739)
Caideyipi Nov 21, 2025
50dd714
Fixed the bug related to "Fixed the bugs related to device auto-creat…
Caideyipi Nov 21, 2025
9488a7e
Load: Remove the getParentFile and exists checks from Load New File (…
luoluoyuyu Nov 24, 2025
ccf4346
Optimized the error message when the column is not tag/attribute in d…
Caideyipi Nov 24, 2025
e54b8a9
Avoid connection reset error log printed (#16797)
HTHou Nov 25, 2025
60e8c63
Fix that settle compaction may lgnore some newly incoming deletions (…
jt2594838 Nov 25, 2025
4582316
Fix slowQueryThreshold & optimize encodeBatch (#16765)
shuwenwei Nov 25, 2025
e34e0fc
Pipe: Adjusted the waiting time of temporary unavailable exceptions (…
Caideyipi Nov 25, 2025
a1b2287
[AINode] Delete poetry.lock for easier maintain different operating s…
CRZbulabula Nov 25, 2025
1b2d3ff
Bump ratis to apache 3.2.1 (#16801)
jt2594838 Nov 26, 2025
7a62fad
Add IT for session and jdbc query
JackieTien97 Nov 26, 2025
db058ab
Pipe: Fixed the check for no permission 2 (#16804)
Caideyipi Nov 26, 2025
e55b423
Update ratis-thirdparty-misc version to 1.0.10 (#16807)
HTHou Nov 26, 2025
cee173b
Fix window partiton across two TsBlock bugs (#16809)
Sh-Zh-7 Nov 26, 2025
d961572
may_fix (#16814)
Caideyipi Nov 26, 2025
32e1642
Fixed the bug of 305 error for unsupported table opreations #16816
Caideyipi Nov 26, 2025
426a964
Fixed the calculation error of schema cache (#16818)
Caideyipi Nov 27, 2025
a280635
Fixed the concurrency issue of region migrate and load (#16796)
Caideyipi Nov 27, 2025
ec7d627
Add 'show available urls' (#16441)
shuwenwei Nov 27, 2025
d33169d
Added back the mis-deleted "()" in last cache (#16824)
Caideyipi Nov 27, 2025
78fcd84
Reduced the auth log when paths are too many (#16825)
Caideyipi Nov 27, 2025
b6d21c6
perf: Optimize wide table write performance (#16699)
luoluoyuyu Nov 28, 2025
8c75110
implement the except (distinct | all ) for table model #16760
alpass163 Nov 28, 2025
53c730c
added support for Blob objects to the length() function, allowing for…
alpass163 Nov 28, 2025
a113051
implement intersect and except related optimization rule: MergeInters…
alpass163 Nov 28, 2025
7249a52
Fix compile error in DataRegion
JackieTien97 Dec 1, 2025
d405afa
fix object functions & add tests for object type & fix some bugs (#16…
shuwenwei Dec 2, 2025
2bdba56
Added name check to avoid directory attack (#16720)
Caideyipi Dec 8, 2025
12325d9
Pipe: Ignore logging when `returnSelf` is called in the event of an e…
luoluoyuyu Dec 2, 2025
6e5bc59
Fixed the schema cache calculation 2 & The potential NPE caused by co…
Caideyipi Dec 2, 2025
41736a5
Fix the check of grant option for tree model (#16845)
shuwenwei Dec 2, 2025
4057642
Pipe: Fixed the bug that lower version tablet may cause NPE when sent…
Caideyipi Dec 2, 2025
57348f5
Pipe: Fixed the auth implementation error (#16847)
Caideyipi Dec 2, 2025
21c64b0
Fix NPE during compaction when disk space is insufficient (#16841)
shuwenwei Dec 3, 2025
42dfbd2
PipePlugin: Optimized the errorCode && Fixed the case-sensitive seman…
Caideyipi Dec 3, 2025
fa96e45
Pipe: Fix NullPointerException in concurrent event access (#16849)
luoluoyuyu Dec 4, 2025
d882a8b
may-c (#16859)
Caideyipi Dec 4, 2025
4b562e6
Pipe: Prevent duplicate error logging in AsyncPipeDataTransferService…
luoluoyuyu Dec 4, 2025
f116081
perf: Optimize TypeManager allocation in StatementAnalyzer (#16870)
luoluoyuyu Dec 5, 2025
6cdd5be
Add system table named connections to resolve the idle session can be…
zerolbsony Dec 5, 2025
03cee80
Switch to at.yawk.lz4:lz4-java:1.10.0 (#16871)
HTHou Dec 5, 2025
c646f3b
Bump at.yawk.lz4:lz4-java from 1.10.0 to 1.10.1 (#16874)
dependabot[bot] Dec 6, 2025
aff27d1
Bump tsfile version to 2.2.0-251208-SNAPSHOT
JackieTien97 Dec 8, 2025
5e29706
Fix compile error caused by `perf: Use enum types for compression and…
JackieTien97 Dec 8, 2025
0d64d51
Fix compile error
JackieTien97 Dec 8, 2025
d64c291
Forbid some interface and add new interface in Record (#16892)
JackieTien97 Dec 10, 2025
55abd0d
Pipe: Fixed the NPE caused by new regions + history only logic (#16879)
Caideyipi Dec 8, 2025
00807e7
Pipe: Fixed the bug that reused plugins may not get loader and visibi…
Caideyipi Dec 8, 2025
ce0e776
Implement PreparedStmt on the Server side (#16764) (#16880)
JackieTien97 Dec 8, 2025
8a903c8
Load: Fix excessive GC caused by loading too many TsFiles at once (#1…
luoluoyuyu Dec 9, 2025
07758a6
Pipe: Modify the TableRawReq deserialization method to support direct…
luoluoyuyu Dec 9, 2025
98f6fb9
Optimize memtable region scan (#16883)
shuwenwei Dec 9, 2025
4554edc
[AINode] Refactoring of Model Storage, Loading, and Inference Pipelin…
CRZbulabula Dec 10, 2025
d308d23
Active Load: Add cleanup for active load listening directories on Dat…
luoluoyuyu Dec 10, 2025
4eda561
Remove the code check port is occupied and resolve the problem that c…
zerolbsony Dec 10, 2025
e6ab914
Remove the code check port is occupied, and resolve the problem that …
zerolbsony Dec 10, 2025
2b12cb6
Support system table current_queries and queries_costs_histogram (#16…
Wei-hao-Li Dec 10, 2025
893e5b1
Bump tsfile version to 2.2.0-251210-SNAPSHOT
JackieTien97 Dec 10, 2025
598311a
Fix NoSuchFile in Object IT
HTHou Dec 11, 2025
ef5cef5
Two Implementation of Object File Path (#16858)
HTHou Dec 16, 2025
8f12358
Throw exception while readObject column is not OBJECT type
JackieTien97 Dec 15, 2025
bc9418a
[AINode] More accurate exception for model management (#16895)
CRZbulabula Dec 11, 2025
2d3c19a
Fix the config 'query_cost_stat_window' cannot be hot loaded #16896
Wei-hao-Li Dec 11, 2025
75e8579
Hotfix concurrent connect error (#16900)
zerolbsony Dec 12, 2025
191edf1
[AINode] More strict concurrent inference IT (#16898)
CRZbulabula Dec 12, 2025
a5c3b43
Delete audit implementation (#16899)
zhujt20 Dec 12, 2025
900ff02
Avoid CN OOM by Pulling User/Roles to DN When Cache Misses. (#16888)
wenyanshi-123 Dec 15, 2025
36cb21f
fix showQueries (#16855)
shuwenwei Dec 15, 2025
bd677fb
Add state predicate push down for system table current_queries (#16904)
Wei-hao-Li Dec 15, 2025
3bc6101
Optimized the error message & prevented stack printing of information…
Caideyipi Dec 16, 2025
b05c45a
Check offset in object related functions
JackieTien97 Dec 16, 2025
ea6dde8
Fix folderManager NPE issue in WALNode when starting iotdb in a disk-…
OneSizeFitsQuorum Dec 16, 2025
d0ad830
Fixed the warn log of internal/MQTT session's close session method (#…
Caideyipi Dec 16, 2025
b4c542d
Fix queryCostStatWindow process of current queries (#16912)
Wei-hao-Li Dec 16, 2025
c82230c
Add Object Type
JackieTien97 Jul 11, 2025
fe19ae8
fix ttl deletion
shuwenwei Jul 12, 2025
f408427
Limit the return size for client instead of always using fetchSize
JackieTien97 Jul 12, 2025
fa17495
Add compress for geo_penetrate
JackieTien97 Jul 13, 2025
baafe25
Fix object table split to multi regions (#15927)
HTHou Jul 14, 2025
637902b
[To object_type] Fix wrong object value inserted (#15928)
HTHou Jul 14, 2025
67f6b60
fix ttl deletion
shuwenwei Jul 14, 2025
d206aa9
fix ttl deletion
shuwenwei Jul 14, 2025
e85dce6
fix multi measurement name
HTHou Jul 15, 2025
f8b3560
cpp client datatype OBJECT (#16094)
hongzhi-gao Aug 5, 2025
c7572ed
make offset of read_object take effective
JackieTien97 Aug 11, 2025
58c4b4f
Print file name while encountering error
JackieTien97 Aug 15, 2025
6b769ea
Print file name while encountering error
JackieTien97 Aug 15, 2025
59803c2
Add object type file metric (#16257)
HTHou Aug 26, 2025
69cdbe9
modify the log of removing object file
shuwenwei Aug 27, 2025
39c33d8
Add object type in CompatibleResolver
JackieTien97 Nov 4, 2025
38033d5
Support In UDF Record
JackieTien97 Nov 5, 2025
0162c2c
disable object type in UDTF
JackieTien97 Nov 5, 2025
9dd7838
[To force_ci/object_type] Support insert object by sql & add IT (#16683)
HTHou Nov 6, 2025
f889340
Add IT for session and jdbc query
JackieTien97 Nov 26, 2025
bea6b43
Fix compile error in DataRegion
JackieTien97 Dec 1, 2025
b23460c
fix object functions & add tests for object type & fix some bugs (#16…
shuwenwei Dec 2, 2025
65c96df
Added name check to avoid directory attack (#16720)
Caideyipi Dec 8, 2025
1db79d2
Bump tsfile version to 2.2.0-251208-SNAPSHOT
JackieTien97 Dec 8, 2025
eb89e08
Fix compile error caused by `perf: Use enum types for compression and…
JackieTien97 Dec 8, 2025
533aa6a
Fix compile error
JackieTien97 Dec 8, 2025
7aefa75
Forbid some interface and add new interface in Record (#16892)
JackieTien97 Dec 10, 2025
d097f7f
Bump tsfile version to 2.2.0-251210-SNAPSHOT
JackieTien97 Dec 10, 2025
3539ec0
Fix NoSuchFile in Object IT
HTHou Dec 11, 2025
3df7063
Two Implementation of Object File Path (#16858)
HTHou Dec 16, 2025
fb38bd9
Throw exception while readObject column is not OBJECT type
JackieTien97 Dec 15, 2025
efc6331
Check offset in object related functions
JackieTien97 Dec 16, 2025
8b3a3d4
resolve conflicts with master
JackieTien97 Dec 18, 2025
38d17b6
spotless AI related codes
CRZbulabula Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void main(String[] args) {
int rowIndex = tablet.getRowSize();
tablet.addTimestamp(rowIndex, timestamp);
tablet.addValue("region_id", rowIndex, "1");
tablet.addValue("plant_id", rowIndex, "5");
tablet.addValue("plant_id", rowIndex, null);
tablet.addValue("device_id", rowIndex, "3");
tablet.addValue("model", rowIndex, "A");
tablet.addValue("temperature", rowIndex, 37.6F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,12 @@ public CommonConfig setAuditableOperationResult(String auditableOperationResult)
return this;
}

@Override
public CommonConfig setRestrictObjectLimit(boolean restrictObjectLimit) {
setProperty("restrict_object_limit", String.valueOf(restrictObjectLimit));
return this;
}

// For part of the log directory
public String getClusterConfigStr() {
return fromConsensusFullNameToAbbr(properties.getProperty(CONFIG_NODE_CONSENSUS_PROTOCOL_CLASS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,11 @@ public CommonConfig setAuditableOperationResult(String auditableOperationResult)
cnConfig.setAuditableOperationResult(auditableOperationResult);
return this;
}

@Override
public CommonConfig setRestrictObjectLimit(boolean restrictObjectLimit) {
cnConfig.setRestrictObjectLimit(restrictObjectLimit);
dnConfig.setRestrictObjectLimit(restrictObjectLimit);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ public String getSystemDir() {
return getDataNodeDir() + File.separator + "system";
}

public String getDataNodeObjectDir() {
return getDataNodeDir() + File.separator + "data" + File.separator + "object";
}

@Override
protected MppJVMConfig initVMConfig() {
return MppJVMConfig.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,4 +477,9 @@ public CommonConfig setAuditableOperationLevel(String auditableOperationLevel) {
public CommonConfig setAuditableOperationResult(String auditableOperationResult) {
return this;
}

@Override
public CommonConfig setRestrictObjectLimit(boolean restrictObjectLimit) {
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,6 @@ default CommonConfig setDefaultDatabaseLevel(int defaultDatabaseLevel) {
CommonConfig setAuditableOperationLevel(String auditableOperationLevel);

CommonConfig setAuditableOperationResult(String auditableOperationResult);

CommonConfig setRestrictObjectLimit(boolean restrictObjectLimit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,12 @@ public Ref getRef(int columnIndex) {
}

@Override
public Blob getBlob(int columnIndex) {
throw new UnsupportedOperationException();
public Blob getBlob(int columnIndex) throws SQLException {
RequestDelegate<Blob> delegate = createLocalRequestDelegate();
for (ResultSet rs : resultSets) {
delegate.addRequest(() -> rs.getBlob(columnIndex));
}
return delegate.requestAllAndCompare();
}

@Override
Expand All @@ -806,8 +810,12 @@ public Ref getRef(String columnLabel) {
}

@Override
public Blob getBlob(String columnLabel) {
throw new UnsupportedOperationException();
public Blob getBlob(String columnLabel) throws SQLException {
RequestDelegate<Blob> delegate = createLocalRequestDelegate();
for (ResultSet rs : resultSets) {
delegate.addRequest(() -> rs.getBlob(columnLabel));
}
return delegate.requestAllAndCompare();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.iotdb.relational.it.query.object;

import org.apache.iotdb.isession.ITableSession;
import org.apache.iotdb.isession.SessionConfig;
import org.apache.iotdb.isession.SessionDataSet;
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
import org.apache.iotdb.itbase.env.BaseEnv;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;

import org.apache.tsfile.enums.TSDataType;
import org.apache.tsfile.read.common.Field;
import org.apache.tsfile.read.common.RowRecord;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
import static org.apache.iotdb.jdbc.IoTDBJDBCResultSet.OBJECT_ERR_MSG;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@RunWith(IoTDBTestRunner.class)
@Category({TableLocalStandaloneIT.class, TableClusterIT.class})
public class IoTDBObjectQueryIT {

private static final String DATABASE_NAME = "test_db";

private static final String TIME_ZONE = "+00:00";

private static final String[] createSqls =
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
"CREATE TABLE t1(device_id STRING TAG, o1 OBJECT, b1 BLOB, s1 STRING)",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(1, 'd1', X'cafebabe01', to_object(true, 0, X'cafebabe01'), 'cafebabe01')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(2, 'd1', X'cafebabe0202', to_object(true, 0, X'cafebabe02'), 'cafebabe02')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(3, 'd1', X'cafebabe0303', to_object(true, 0, X'cafebabe03'), 'cafebabe03')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(4, 'd1', X'cafebabe04', to_object(true, 0, X'cafebabe04'), 'cafebabe04')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(1, 'd2', X'cafebade01', to_object(true, 0, X'cafebade01'), 'cafebade01')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(2, 'd2', X'cafebade0202', to_object(true, 0, X'cafebade02'), 'cafebade02')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(3, 'd2', X'cafebade0302', to_object(true, 0, X'cafebade03'), 'cafebade03')",
"INSERT INTO t1(time, device_id, b1, o1, s1) VALUES(4, 'd2', X'cafebade04', to_object(true, 0, X'cafebade04'), 'cafebade04')",
"FLUSH",
};

@BeforeClass
public static void classSetUp() {
EnvFactory.getEnv().initClusterEnvironment();
prepareTableData(createSqls);
}

@AfterClass
public static void classTearDown() {
EnvFactory.getEnv().cleanClusterEnvironment();
}

@Test
public void jdbcTest() {
try (Connection connection =
EnvFactory.getEnv()
.getConnection(
SessionConfig.DEFAULT_USER,
SessionConfig.DEFAULT_PASSWORD,
BaseEnv.TABLE_SQL_DIALECT)) {
connection.setClientInfo("time_zone", TIME_ZONE);
try (Statement statement = connection.createStatement()) {
statement.execute("use " + DATABASE_NAME);
try (ResultSet resultSet =
statement.executeQuery(
"SELECT time, b1, o1, s1 FROM t1 WHERE device_id = 'd1' ORDER BY time")) {
int cnt = 0;
while (resultSet.next()) {
cnt++;
try {
resultSet.getBlob(3);
fail();
} catch (SQLException e) {
assertEquals(OBJECT_ERR_MSG, e.getMessage());
}

try {
resultSet.getBytes("o1");
fail();
} catch (SQLException e) {
assertEquals(OBJECT_ERR_MSG, e.getMessage());
}

String s = resultSet.getString(3);
assertEquals("(Object) 5 B", s);
}
assertEquals(4, cnt);
}

try (ResultSet resultSet =
statement.executeQuery(
"SELECT time, b1, READ_OBJECT(o1), s1 FROM t1 WHERE device_id = 'd2' AND READ_OBJECT(o1)=b1 ORDER BY time")) {
int cnt = 0;
String[] ans = {"0xcafebade01", "0xcafebade04"};
while (resultSet.next()) {
String s = resultSet.getString(3);
assertEquals(ans[cnt], s);
cnt++;
}
assertEquals(2, cnt);
}
}
} catch (SQLException e) {
e.printStackTrace();
fail(e.getMessage());
}
}

@Test
public void sessionTest() {
try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
session.executeNonQueryStatement("USE " + DATABASE_NAME);

// SessionDataSet
try (SessionDataSet dataSet =
session.executeQueryStatement(
"SELECT time, b1, o1, s1 FROM t1 WHERE device_id = 'd1' ORDER BY time")) {
int cnt = 0;
while (dataSet.hasNext()) {
cnt++;
RowRecord rowRecord = dataSet.next();
Field field = rowRecord.getField(2);
String s = field.getStringValue();
assertEquals("(Object) 5 B", s);
Object blob = field.getObjectValue(TSDataType.OBJECT);
assertTrue(blob instanceof String);
assertEquals("(Object) 5 B", blob);

try {
field.getBinaryV();
fail();
} catch (UnsupportedOperationException e) {
assertEquals("OBJECT Type only support getStringValue", e.getMessage());
}
}
assertEquals(4, cnt);
}

// SessionDataSet.DataIterator
try (SessionDataSet dataSet =
session.executeQueryStatement(
"SELECT time, b1, o1, s1 FROM t1 WHERE device_id = 'd2' ORDER BY time")) {
SessionDataSet.DataIterator iterator = dataSet.iterator();
int cnt = 0;
while (iterator.next()) {
cnt++;
Object o = iterator.getObject(3);
assertTrue(o instanceof String);
assertEquals("(Object) 5 B", o);
String s = iterator.getString("o1");
assertEquals("(Object) 5 B", s);
try {
iterator.getBlob(3);
fail();
} catch (StatementExecutionException e) {
assertEquals("OBJECT Type only support getString", e.getMessage());
}
}
assertEquals(4, cnt);
}
} catch (IoTDBConnectionException | StatementExecutionException e) {
fail(e.getMessage());
}
}
}
Loading