Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: populate users fields for sentAt, timestamp and originalTimestamp #3753

Merged
merged 1 commit into from
Sep 24, 2024
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
14 changes: 13 additions & 1 deletion src/warehouse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,23 @@ function processWarehouseMessage(message, options) {

const usersEvent = { ...commonProps };
const usersColumnTypes = {};
let userColumnMappingRules = whUserColumnMappingRules;
if (!isDataLakeProvider(options.provider)) {
Copy link
Member Author

@achettyiitr achettyiitr Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are populating it for all non Datalake destinations because there are few destinations like CLICKHOUSE, RS, POSTGRES where load files are being used in certain configurations to load the data. Here we can see there are 3 empty fields present which are sentAt, timestamp and originalTimestamp.

  1. UploadJobUsersAppendRecordsUsingUsersLoadFiles
  2. UploadJobUsersRecordsUsingUsersLoadFilesForClickhouse

Once these changes are merged we would need to update these test cases as well in rudder-server.

userColumnMappingRules = {
...userColumnMappingRules,
...{
sent_at: 'sentAt',
timestamp: 'timestamp',
original_timestamp: 'originalTimestamp',
},
};
}

setDataFromColumnMappingAndComputeColumnTypes(
utils,
usersEvent,
message,
whUserColumnMappingRules,
userColumnMappingRules,
usersColumnTypes,
options,
);
Expand Down
278 changes: 278 additions & 0 deletions test/__tests__/data/warehouse/integration_options_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,9 @@ const sampleEvents = {
"email": "[email protected]",
"id": "user123",
"phone": "+917836362334",
"sent_at": "2021-01-03T17:02:53.195Z",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"timestamp": "2020-01-24T06:29:02.403Z",
"received_at": "2020-01-24T06:29:02.403Z"
},
"metadata": {
Expand All @@ -906,6 +909,9 @@ const sampleEvents = {
"id": "string",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"timestamp": "datetime",
"original_timestamp": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1074,6 +1080,9 @@ const sampleEvents = {
"email": "[email protected]",
"id": "user123",
"phone": "+917836362334",
"sent_at": "2021-01-03T17:02:53.195Z",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"timestamp": "2020-01-24T06:29:02.403Z",
"received_at": "2020-01-24T06:29:02.403Z"
},
"metadata": {
Expand Down Expand Up @@ -1101,6 +1110,9 @@ const sampleEvents = {
"loaded_at": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"timestamp": "datetime",
"original_timestamp": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1199,6 +1211,9 @@ const sampleEvents = {
"EMAIL": "[email protected]",
"ID": "user123",
"PHONE": "+917836362334",
"SENT_AT": "2021-01-03T17:02:53.195Z",
"ORIGINAL_TIMESTAMP": "2020-01-24T06:29:02.364Z",
"TIMESTAMP": "2020-01-24T06:29:02.403Z",
"RECEIVED_AT": "2020-01-24T06:29:02.403Z"
},
"metadata": {
Expand All @@ -1225,6 +1240,9 @@ const sampleEvents = {
"ID": "string",
"PHONE": "string",
"RECEIVED_AT": "datetime",
"SENT_AT": "datetime",
"TIMESTAMP": "datetime",
"ORIGINAL_TIMESTAMP": "datetime",
"UUID_TS": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
Expand Down Expand Up @@ -1355,6 +1373,254 @@ const sampleEvents = {
"table": "users"
}
}
],
gcs_datalake: [
{
"data": {
"timestamp": "2020-01-24T06:29:02.403Z",
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
"context_app_version": "1.1.11",
"context_device_id": "id",
"context_device_token": "token",
"context_device_type": "ios",
"context_ip": "[::1]:53708",
"context_library_name": "RudderLabs JavaScript SDK",
"context_library_version": "1.1.11",
"context_locale": "en-US",
"context_os_name": "android",
"context_os_version": "1.12.3",
"context_request_ip": "[::1]:53708",
"context_traits_email": "[email protected]",
"context_traits_phone": "+917836362334",
"context_traits_user_id": "user123",
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"user_id": "user123"
},
"metadata": {
"columns": {
"timestamp": "datetime",
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
"context_app_version": "string",
"context_device_id": "string",
"context_device_token": "string",
"context_device_type": "string",
"context_ip": "string",
"context_library_name": "string",
"context_library_version": "string",
"context_locale": "string",
"context_os_name": "string",
"context_os_version": "string",
"context_request_ip": "string",
"context_traits_email": "string",
"context_traits_phone": "string",
"context_traits_user_id": "string",
"context_user_agent": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"user_id": "string",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
"table": "identifies"
}
},
{
"data": {
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
"context_app_version": "1.1.11",
"context_device_id": "id",
"context_device_token": "token",
"context_device_type": "ios",
"context_ip": "[::1]:53708",
"context_library_name": "RudderLabs JavaScript SDK",
"context_library_version": "1.1.11",
"context_locale": "en-US",
"context_os_name": "android",
"context_os_version": "1.12.3",
"context_request_ip": "[::1]:53708",
"context_traits_email": "[email protected]",
"context_traits_phone": "+917836362334",
"context_traits_user_id": "user123",
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "user123",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z"
},
"metadata": {
"columns": {
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
"context_app_version": "string",
"context_device_id": "string",
"context_device_token": "string",
"context_device_type": "string",
"context_ip": "string",
"context_library_name": "string",
"context_library_version": "string",
"context_locale": "string",
"context_os_name": "string",
"context_os_version": "string",
"context_request_ip": "string",
"context_traits_email": "string",
"context_traits_phone": "string",
"context_traits_user_id": "string",
"context_user_agent": "string",
"email": "string",
"id": "string",
"phone": "string",
"received_at": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
"table": "users"
}
}
],
azure_datalake: [
{
"data": {
"timestamp": "2020-01-24T06:29:02.403Z",
"anonymous_id": "97c46c81-3140-456d-b2a9-690d70aaca35",
"channel": "web",
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
"context_app_version": "1.1.11",
"context_device_id": "id",
"context_device_token": "token",
"context_device_type": "ios",
"context_ip": "[::1]:53708",
"context_library_name": "RudderLabs JavaScript SDK",
"context_library_version": "1.1.11",
"context_locale": "en-US",
"context_os_name": "android",
"context_os_version": "1.12.3",
"context_request_ip": "[::1]:53708",
"context_traits_email": "[email protected]",
"context_traits_phone": "+917836362334",
"context_traits_user_id": "user123",
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "2116ef8c-efc3-4ca4-851b-02ee60dad6ff",
"original_timestamp": "2020-01-24T06:29:02.364Z",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z",
"sent_at": "2021-01-03T17:02:53.195Z",
"user_id": "user123"
},
"metadata": {
"columns": {
"timestamp": "datetime",
"anonymous_id": "string",
"channel": "string",
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
"context_app_version": "string",
"context_device_id": "string",
"context_device_token": "string",
"context_device_type": "string",
"context_ip": "string",
"context_library_name": "string",
"context_library_version": "string",
"context_locale": "string",
"context_os_name": "string",
"context_os_version": "string",
"context_request_ip": "string",
"context_traits_email": "string",
"context_traits_phone": "string",
"context_traits_user_id": "string",
"context_user_agent": "string",
"email": "string",
"id": "string",
"original_timestamp": "datetime",
"phone": "string",
"received_at": "datetime",
"sent_at": "datetime",
"user_id": "string",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
"table": "identifies"
}
},
{
"data": {
"context_app_build": "1.0.0",
"context_app_name": "RudderLabs JavaScript SDK",
"context_app_namespace": "com.rudderlabs.javascript",
"context_app_version": "1.1.11",
"context_device_id": "id",
"context_device_token": "token",
"context_device_type": "ios",
"context_ip": "[::1]:53708",
"context_library_name": "RudderLabs JavaScript SDK",
"context_library_version": "1.1.11",
"context_locale": "en-US",
"context_os_name": "android",
"context_os_version": "1.12.3",
"context_request_ip": "[::1]:53708",
"context_traits_email": "[email protected]",
"context_traits_phone": "+917836362334",
"context_traits_user_id": "user123",
"context_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:84.0) Gecko/20100101 Firefox/84.0",
"email": "[email protected]",
"id": "user123",
"phone": "+917836362334",
"received_at": "2020-01-24T06:29:02.403Z"
},
"metadata": {
"columns": {
"context_app_build": "string",
"context_app_name": "string",
"context_app_namespace": "string",
"context_app_version": "string",
"context_device_id": "string",
"context_device_token": "string",
"context_device_type": "string",
"context_ip": "string",
"context_library_name": "string",
"context_library_version": "string",
"context_locale": "string",
"context_os_name": "string",
"context_os_version": "string",
"context_request_ip": "string",
"context_traits_email": "string",
"context_traits_phone": "string",
"context_traits_user_id": "string",
"context_user_agent": "string",
"email": "string",
"id": "string",
"phone": "string",
"received_at": "datetime",
"uuid_ts": "datetime"
},
"receivedAt": "2020-01-24T11:59:02.403+05:30",
"table": "users"
}
}
]
}
}
Expand All @@ -1374,6 +1640,18 @@ function opOutput(eventType, provider) {
return _.cloneDeep(sampleEvents[eventType].output.rs);
case "bq":
return _.cloneDeep(sampleEvents[eventType].output.bq);
case "gcs_datalake":
if (eventType === 'users') {
return _.cloneDeep(sampleEvents[eventType].output.gcs_datalake);
} else {
return _.cloneDeep(sampleEvents[eventType].output.default);
}
case "azure_datalake":
if (eventType === 'users') {
return _.cloneDeep(sampleEvents[eventType].output.azure_datalake);
} else {
return _.cloneDeep(sampleEvents[eventType].output.default);
}
default:
return _.cloneDeep(sampleEvents[eventType].output.default);
}
Expand Down
Loading
Loading