Interface SnowflakeStreamingIngestChannel


  • public interface SnowflakeStreamingIngestChannel
    A logical partition that represents a connection to a single Snowflake table, data will be ingested into the channel, and then flushed to Snowflake table periodically in the background.

    Channels are identified by their name and only one channel with the same name may ingest data at the same time. When a new channel is opened, all previously opened channels with the same name are invalidated (this applies for the table globally. not just in a single JVM). In order to ingest data from multiple threads/clients/applications, we recommend opening multiple channels, each with a different name.

    Thread safety note: Implementations of this interface are required to be thread safe.

    • Method Detail

      • getFullyQualifiedName

        String getFullyQualifiedName()
        Get the fully qualified channel name
        Returns:
        fully qualified name of the channel, in the format of dbName.schemaName.tableName.channelName
      • getName

        String getName()
        Get the name of the channel
        Returns:
        name of the channel
      • getDBName

        String getDBName()
        Get the database name
        Returns:
        name of the database
      • getSchemaName

        String getSchemaName()
        Get the schema name
        Returns:
        name of the schema
      • getTableName

        String getTableName()
        Get the table name
        Returns:
        name of the table
      • getFullyQualifiedTableName

        String getFullyQualifiedTableName()
        Get the fully qualified table name that the channel belongs to
        Returns:
        fully qualified table name, in the format of dbName.schemaName.tableName
      • isValid

        boolean isValid()
        Returns:
        a boolean which indicates whether the channel is valid
      • isClosed

        boolean isClosed()
        Returns:
        a boolean which indicates whether the channel is closed
      • close

        CompletableFuture<Void> close()
        Close the channel, this function will make sure all the data in this channel is committed
        Returns:
        a completable future which will be completed when the channel is closed
      • close

        CompletableFuture<Void> close​(boolean drop)
        Close the channel, this function will make sure all the data in this channel is committed

        Note that this call with drop=true will delete Offset Token and other state from Snowflake servers unless the channel has already been opened in another client. So only use it if you are completely done ingesting data for this channel. If you open a channel with the same name in the future, it will behave like a new channel.

        Parameters:
        drop - if true, the channel will be dropped after all data is successfully committed.
        Returns:
        a completable future which will be completed when the channel is closed
      • insertRows

        InsertValidationResponse insertRows​(Iterable<Map<String,​Object>> rows,
                                            @Nullable
                                            String startOffsetToken,
                                            @Nullable
                                            String endOffsetToken)
        Insert a batch of rows into the channel, each row is represented using Map where the key is column name and the value is a row of data. See insertRow(Map, String) for more information about accepted values.
        Parameters:
        rows - object data to write
        startOffsetToken - start offset of the batch/row-set
        endOffsetToken - end offset of the batch/row-set, used for replay in case of failures, * It could be null if you don't plan on replaying or can't replay
        Returns:
        insert response that possibly contains errors because of insertion failures
      • getLatestCommittedOffsetToken

        @Nullable
        String getLatestCommittedOffsetToken()
        Get the latest committed offset token from Snowflake
        Returns:
        the latest committed offset token
      • getTableSchema

        Map<String,​ColumnProperties> getTableSchema()
        Gets the table schema associated with this channel. Note that this is the table schema at the time of a channel open event. The schema may be changed on the Snowflake side in which case this will continue to show an old schema version until the channel is re-opened.
        Returns:
        map representing Column Name to Column Properties