Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -385,4 +385,60 @@ public void testIoTDBPatternWithExclusionRealtimeData() throws Exception {
"Time,root.db.d1.t,root.db.d2.s,",
expectedResSet);
}

@Test
public void testIoTDBPatternWithExclusionOnlyHistoricalData() throws Exception {
final Map<String, String> sourceAttributes = new HashMap<>();
sourceAttributes.put("source.pattern.exclusion", "root.db.d1.s*, root.db.d3.*");
sourceAttributes.put("source.inclusion", "data.insert");
sourceAttributes.put("user", "root");

final List<String> insertQueries =
Arrays.asList(
"insert into root.db.d1(time, s, s1, t) values (1, 1, 1, 1)",
"insert into root.db.d2(time, s) values (2, 2)",
"insert into root.db.d3(time, s) values (3, 3)",
"insert into root.db1.d1(time, s) values (4, 4)");

final Set<String> expectedResSet = new HashSet<>();
expectedResSet.add("1,null,1.0,null,");
expectedResSet.add("2,null,null,2.0,");
expectedResSet.add("4,4.0,null,null,");

testPipeWithMultiplePatterns(
sourceAttributes,
insertQueries,
true, // isHistorical = true
"select * from root.db1.**,root.db.**",
"Time,root.db1.d1.s,root.db.d1.t,root.db.d2.s,",
expectedResSet);
}

@Test
public void testIoTDBPatternWithExclusionOnlyRealtimeData() throws Exception {
final Map<String, String> sourceAttributes = new HashMap<>();
sourceAttributes.put("source.pattern.exclusion", "root.db.d1.s*, root.db.d3.*");
sourceAttributes.put("source.inclusion", "data.insert");
sourceAttributes.put("user", "root");

final List<String> insertQueries =
Arrays.asList(
"insert into root.db.d1(time, s, s1, t) values (1, 1, 1, 1)",
"insert into root.db.d2(time, s) values (2, 2)",
"insert into root.db.d3(time, s) values (3, 3)",
"insert into root.db1.d1(time, s) values (4, 4)");

final Set<String> expectedResSet = new HashSet<>();
expectedResSet.add("1,null,1.0,null,");
expectedResSet.add("2,null,null,2.0,");
expectedResSet.add("4,4.0,null,null,");

testPipeWithMultiplePatterns(
sourceAttributes,
insertQueries,
false, // isHistorical = false
"select * from root.db1.**,root.db.**",
"Time,root.db1.d1.s,root.db.d1.t,root.db.d2.s,",
expectedResSet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,16 @@ public static TreePattern parsePipePatternFromSourceParametersInternal(
final boolean hasPatternInclusionKey =
sourceParameters.hasAnyAttributes(
EXTRACTOR_PATTERN_INCLUSION_KEY, SOURCE_PATTERN_INCLUSION_KEY);
final boolean hasPatternExclusionKey =
sourceParameters.hasAnyAttributes(
EXTRACTOR_PATTERN_EXCLUSION_KEY, SOURCE_PATTERN_EXCLUSION_KEY);
final boolean hasLegacyPathKey =
sourceParameters.hasAnyAttributes(EXTRACTOR_PATH_KEY, SOURCE_PATH_KEY);
final boolean hasLegacyPatternKey =
sourceParameters.hasAnyAttributes(EXTRACTOR_PATTERN_KEY, SOURCE_PATTERN_KEY);
final boolean usePatternSyntax =
hasPatternInclusionKey
|| (hasPatternExclusionKey && !hasLegacyPathKey && !hasLegacyPatternKey);

if (hasPatternInclusionKey && (hasLegacyPathKey || hasLegacyPatternKey)) {
final String msg =
Expand All @@ -172,7 +178,7 @@ public static TreePattern parsePipePatternFromSourceParametersInternal(

// 1. Parse INCLUSION patterns into a list
List<TreePattern> inclusionPatterns =
hasPatternInclusionKey
usePatternSyntax
? parseIoTDBPatternList(
sourceParameters.getStringByKeys(
EXTRACTOR_PATTERN_INCLUSION_KEY, SOURCE_PATTERN_INCLUSION_KEY),
Expand All @@ -198,7 +204,7 @@ public static TreePattern parsePipePatternFromSourceParametersInternal(
}

// 2. Parse EXCLUSION patterns into a list
if (hasPatternInclusionKey
if (usePatternSyntax
&& sourceParameters.hasAnyAttributes(
EXTRACTOR_PATH_EXCLUSION_KEY, SOURCE_PATH_EXCLUSION_KEY)) {
final String msg =
Expand All @@ -210,7 +216,7 @@ public static TreePattern parsePipePatternFromSourceParametersInternal(
}

List<TreePattern> exclusionPatterns =
hasPatternInclusionKey
usePatternSyntax
? parseIoTDBPatternList(
sourceParameters.getStringByKeys(
EXTRACTOR_PATTERN_EXCLUSION_KEY, SOURCE_PATTERN_EXCLUSION_KEY),
Expand Down
Loading