Skip to content

Commit

Permalink
Merge branch 'develop' into fix.dedicated-braze-subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik authored Dec 9, 2024
2 parents d565ce6 + 12621c8 commit b7c27a0
Show file tree
Hide file tree
Showing 22 changed files with 2,120 additions and 139 deletions.
27 changes: 26 additions & 1 deletion src/v0/destinations/snowpipe_streaming/transform.js
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
module.exports = require('../snowflake/transform');
const transform = require('../snowflake/transform');
const { processWarehouseMessage } = require('../../../warehouse');

const provider = 'snowpipe_streaming';

function process(event) {
const whSchemaVersion = event.request.query.whSchemaVersion || 'v1';
const whStoreEvent = event.destination.Config.storeFullEvent === true;
const destJsonPaths = event.destination?.Config?.jsonPaths || '';
return processWarehouseMessage(event.message, {
metadata: event.metadata,
whSchemaVersion,
whStoreEvent,
getDataTypeOverride: transform.getDataTypeOverride,
provider,
sourceCategory: event.metadata ? event.metadata.sourceCategory : null,
destJsonPaths,
destConfig: event.destination?.Config,
});
}

module.exports = {
provider,
process,
getDataTypeOverride: transform.getDataTypeOverride,
};
93 changes: 93 additions & 0 deletions src/warehouse/config/ReservedKeywords.json
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,99 @@
"WHERE": true,
"WITH": true
},
"SNOWPIPE_STREAMING": {
"ACCOUNT": true,
"ALL": true,
"ALTER": true,
"AND": true,
"ANY": true,
"AS": true,
"BETWEEN": true,
"BY": true,
"CASE": true,
"CAST": true,
"CHECK": true,
"COLUMN": true,
"CONNECT": true,
"CONNECTION": true,
"CONSTRAINT": true,
"CREATE": true,
"CROSS": true,
"CURRENT": true,
"CURRENT_DATE": true,
"CURRENT_TIME": true,
"CURRENT_TIMESTAMP": true,
"CURRENT_USER": true,
"DATABASE": true,
"DELETE": true,
"DISTINCT": true,
"DROP": true,
"ELSE": true,
"EXISTS": true,
"FALSE": true,
"FOLLOWING": true,
"FOR": true,
"FROM": true,
"FULL": true,
"GRANT": true,
"GROUP": true,
"GSCLUSTER": true,
"HAVING": true,
"ILIKE": true,
"IN": true,
"INCREMENT": true,
"INNER": true,
"INSERT": true,
"INTERSECT": true,
"INTO": true,
"IS": true,
"ISSUE": true,
"JOIN": true,
"LATERAL": true,
"LEFT": true,
"LIKE": true,
"LOCALTIME": true,
"LOCALTIMESTAMP": true,
"MINUS": true,
"NATURAL": true,
"NOT": true,
"NULL": true,
"OF": true,
"ON": true,
"OR": true,
"ORDER": true,
"ORGANIZATION": true,
"QUALIFY": true,
"REGEXP": true,
"REVOKE": true,
"RIGHT": true,
"RLIKE": true,
"ROW": true,
"ROWS": true,
"SAMPLE": true,
"SCHEMA": true,
"SELECT": true,
"SET": true,
"SOME": true,
"START": true,
"TABLE": true,
"TABLESAMPLE": true,
"THEN": true,
"TO": true,
"TRIGGER": true,
"TRUE": true,
"TRY_CAST": true,
"UNION": true,
"UNIQUE": true,
"UPDATE": true,
"USING": true,
"VALUES": true,
"VIEW": true,
"WHEN": true,
"WHENEVER": true,
"WHERE": true,
"WITH": true
},
"CLICKHOUSE": {},
"S3_DATALAKE": {
"ALL": true,
Expand Down
18 changes: 15 additions & 3 deletions src/warehouse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ function stringLikeObjectToString(obj) {
*/
function getColumns(options, event, columnTypes) {
const columns = {};
const uuidTS = options.provider === 'snowflake' ? 'UUID_TS' : 'uuid_ts';
const uuidTS =
options.provider === 'snowflake' || options.provider === 'snowpipe_streaming'
? 'UUID_TS'
: 'uuid_ts';
columns[uuidTS] = 'datetime';
// add loaded_at for bq to be segment compatible
if (options.provider === 'bq') {
Expand Down Expand Up @@ -377,6 +380,7 @@ function getColumns(options, event, columnTypes) {

const fullEventColumnTypeByProvider = {
snowflake: 'json',
snowpipe_streaming: 'json',
rs: 'text',
bq: 'string',
postgres: 'json',
Expand Down Expand Up @@ -613,6 +617,15 @@ function enhanceContextWithSourceDestInfo(message, metadata) {
message.context = context;
}

function shouldSkipUsersTable(options) {
return (
options.provider === 'snowpipe_streaming' ||
options.destConfig?.skipUsersTable ||
options.integrationOptions?.skipUsersTable ||
false
);
}

function processWarehouseMessage(message, options) {
const utils = getVersionedUtils(options.whSchemaVersion);
options.utils = utils;
Expand All @@ -638,8 +651,7 @@ function processWarehouseMessage(message, options) {
const eventType = message.type?.toLowerCase();
const skipTracksTable =
options.destConfig?.skipTracksTable || options.integrationOptions.skipTracksTable || false;
const skipUsersTable =
options.destConfig?.skipUsersTable || options.integrationOptions.skipUsersTable || false;
const skipUsersTable = shouldSkipUsersTable(options);
const skipReservedKeywordsEscaping =
options.integrationOptions.skipReservedKeywordsEscaping || false;

Expand Down
4 changes: 2 additions & 2 deletions src/warehouse/v1/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function safeTableName(options, name = '') {
if (tableName === '') {
throw new TransformationError('Table name cannot be empty.');
}
if (provider === 'snowflake') {
if (provider === 'snowflake' || provider === 'snowpipe_streaming') {
tableName = tableName.toUpperCase();
} else if (provider === 'postgres') {
tableName = tableName.substr(0, 63);
Expand Down Expand Up @@ -41,7 +41,7 @@ function safeColumnName(options, name = '') {
if (columnName === '') {
throw new TransformationError('Column name cannot be empty.');
}
if (provider === 'snowflake') {
if (provider === 'snowflake' || provider === 'snowpipe_streaming') {
columnName = columnName.toUpperCase();
} else if (provider === 'postgres') {
columnName = columnName.substr(0, 63);
Expand Down
Loading

0 comments on commit b7c27a0

Please sign in to comment.