forked from snowflakedb/snowflake-kafka-connector
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-1642799: added exception handler when moving invalid file to tab…
…le stage; file cleaner will preserve 'dirty' files a bit longer (snowflakedb#931) (#72) Co-authored-by: Greg Jachimko <[email protected]>
- Loading branch information
1 parent
a4dde8f
commit 6c2ce0e
Showing
17 changed files
with
726 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/com/snowflake/kafka/connector/config/TopicToTableModeExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.snowflake.kafka.connector.config; | ||
|
||
import com.snowflake.kafka.connector.Utils; | ||
import java.util.Map; | ||
|
||
public class TopicToTableModeExtractor { | ||
|
||
/** Defines whether single target table is fed by one or many source topics. */ | ||
public enum Topic2TableMode { | ||
// Single topic = single table | ||
SINGLE_TOPIC_SINGLE_TABLE, | ||
// Multiple topics = single table | ||
MANY_TOPICS_SINGLE_TABLE, | ||
} | ||
|
||
private TopicToTableModeExtractor() {} | ||
|
||
/** | ||
* Util method - checks if given topic is defined in topic2Table map - if it is more than once, it | ||
* means multiple topics will store data in single table - in such case, for SNOWPIPE ingestion we | ||
* need to uniquely identify stage files so different instances of file cleaner won't handle | ||
* other's channel files. | ||
* | ||
* @param topic | ||
* @return | ||
*/ | ||
public static Topic2TableMode determineTopic2TableMode( | ||
Map<String, String> topic2TableMap, String topic) { | ||
String tableName = Utils.tableName(topic, topic2TableMap); | ||
return topic2TableMap.values().stream() | ||
.filter(table -> table.equalsIgnoreCase(tableName)) | ||
.count() | ||
> 1 | ||
? Topic2TableMode.MANY_TOPICS_SINGLE_TABLE | ||
: Topic2TableMode.SINGLE_TOPIC_SINGLE_TABLE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.