Skip to content

fix: warehouse transformations mismatches - #5779

Merged
achettyiitr merged 4 commits into
release/1.48.xfrom
fix.warebhouse-transformations
May 7, 2025
Merged

achettyiitr merged 4 commits into
release/1.48.xfrom
fix.warebhouse-transformations

Conversation

@achettyiitr

@achettyiitr achettyiitr commented Apr 28, 2025 •

Copy link
Copy Markdown
Member

Description

  • For string length calculation, always use utf8.RuneCount instead of len function to be compatible with JavaScript.
  • Extract event name is coming as empty because rules calculation was being done later to the event name calculation.
  • Using receivedAt from metadata if empty in the event.
  • Extract recordID to be empty in case of slices.
  • For getting event type use event instead of metadata.
  • While doing JSON marshalling, handle HTML Unicode characters. By default, during marshalling, SetEscapeHTML is true. During Unmarshalling, the library is already taking care of the unescape. So if we do both Marshalling and UnMarshalling, there would be no effect,t which is why it's working for the Transformer response. But here in the warehouse, the transformer would need to handle it separately.
  • Additional datetime formats for 2006-01-02T15:04:05.000-0700, 2006-01-02 15:04:05.000000-07:00, 2006-01-02 15:04:05+00:00. New data formats keep popping up. And it would be difficult to maintain list of supported date time formats. Also, with the current logic of iterating to valid formats and finding the the valid one will become more expensive if the list grows too long. Moving to existing implementation of using dateparser.Any.
    // BenchmarkValidTimestamp
    // BenchmarkValidTimestamp/old_parser
    // BenchmarkValidTimestamp/old_parser-12         	    6999	    163017 ns/op
    // BenchmarkValidTimestamp/new_parser
    // BenchmarkValidTimestamp/new_parser-12         	   89427	     13392 ns/op
    
  • Modify IsBlank for maps and slice of to be compatible with _.isEmpty(_.toString(value)). Corresponding lodash implementation: https://playcode.io/2371369

Linear Ticket

  • Resolves WAR-621, WAR-584, WAR-583, WAR-622, WAR-623, WAR-586, WAR-582, WAR-585.

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@achettyiitr
achettyiitr force-pushed the fix.warebhouse-transformations branch 3 times, most recently from 92bb4a6 to e6fb943 Compare April 28, 2025 09:30
@codecov

codecov Bot commented Apr 28, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 81.41593% with 21 lines in your changes missing coverage. Please review.

Project coverage is 76.83%. Comparing base (0044650) to head (ace3e77).
Report is 1 commits behind head on release/1.48.x.

Files with missing lines Patch % Lines
warehouse/transformer/events.go 62.79% 10 Missing and 6 partials ⚠️
warehouse/transformer/internal/utils/utils.go 90.90% 2 Missing and 1 partial ⚠️
warehouse/transformer/logger.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release/1.48.x    #5779      +/-   ##
==================================================
- Coverage           76.89%   76.83%   -0.06%     
==================================================
  Files                 490      490              
  Lines               67081    67137      +56     
==================================================
+ Hits                51580    51588       +8     
- Misses              12685    12720      +35     
- Partials             2816     2829      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@achettyiitr
achettyiitr force-pushed the fix.warebhouse-transformations branch 2 times, most recently from 0fa2494 to b5d02f6 Compare May 6, 2025 13:46
@achettyiitr
achettyiitr changed the base branch from master to release/1.48.x May 6, 2025 13:46
@achettyiitr
achettyiitr force-pushed the fix.warebhouse-transformations branch from b5d02f6 to 18dd7a1 Compare May 6, 2025 14:47
@achettyiitr
achettyiitr requested a review from vyeshwanth May 6, 2025 14:48
@achettyiitr
achettyiitr force-pushed the fix.warebhouse-transformations branch from 18dd7a1 to 3f15029 Compare May 6, 2025 14:58
@achettyiitr
achettyiitr force-pushed the fix.warebhouse-transformations branch from 3f15029 to ace3e77 Compare May 6, 2025 15:00
Comment thread warehouse/transformer/datatype.go Outdated
Comment on lines 86 to 90

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For string length calculation, always use utf8.RuneCount instead of len function to be compatible with JavaScript.

@RanjeetMishra RanjeetMishra May 7, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@achettyiitr Fine to be compatible with js transformation. But if its about refshiftString size limit, ideally we should account for bytes than character count? And for this change, once we disable comparison we can move to len?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, later we can move to bytes.

Comment thread warehouse/transformer/events.go Outdated
Comment on lines 167 to 169

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extract event name is coming as empty because rules calculation was being done later to the event name calculation.

  • Moved the logic to extractCommonProps along with handling of setDataAndMetadataFromRules which populated the event name.
  • Also, for getting the event name need to check Output instead of event message.
  • Added tests for Snowflake destinations for all event types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@achettyiitr Extract event name is coming as empty Was it only for some events? Trying to understand if this was some edge scenario vs consistent issue and this being identified now?

@achettyiitr achettyiitr May 7, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was happening only for Snowflake destination with extract event type, as in we were checking the event message instead of Output for event name. Since for Snowflake keys are caps, it was not able to find anything with EVENT key in message.

Comment on lines 226 to 237

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Using receivedAt from metadata if empty in the event.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Extract recordID to be empty in case of slices.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this change mean that RecordID being slice is not a valid event?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, recordID should not be an object or an array.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, is this some bug in ETL? Why we would get a non-string record id?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure though. But in the debug sample payloads that we receive it came in as Array.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can happen with bug in etl connector as in field being defined as identifier which can be array. @am6010 In case you remember any from top of your mind.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For getting event type use event instead of metadata

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have not been able to understand these switches ... some from metadata, some from event 😅

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For an event, type was coming as empty but metadata was having something. Not sure whether it's a valid case from server side. But since rudder-transformer relies on event payload rather then metadata, we need to move to event payload.

	wEvent.Metadata.MessageID = utils.ExtractMessageID(event, uuidGenerator) -- This needs to be using event
	wEvent.Metadata.ReceivedAt = utils.ExtractReceivedAt(event, now) -- This needs to be using event
	wEvent.Metadata.SourceID = event.Metadata.SourceID -- For this we need to use metadata only
	wEvent.Metadata.SourceType = event.Metadata.SourceType -- For this we need to use metadata only
	wEvent.Metadata.DestinationID = event.Metadata.DestinationID -- For this we need to use metadata only
	wEvent.Metadata.DestinationType = event.Metadata.DestinationType -- For this we need to use metadata only
	wEvent.Metadata.SourceCategory = event.Metadata.SourceCategory -- For this we need to use metadata only
	wEvent.Metadata.EventType = utils.ToString(event.Message["type"]) -- This needs to be using event
	wEvent.Metadata.RecordID = event.Metadata.RecordID -- If we find something, we can later as well move this to using event.

Comment thread warehouse/transformer/set.go Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While doing JSON marshalling, handle HTML Unicode characters. By default, during marshalling, SetEscapeHTML is true. During Unmarshalling, the library is already taking care of the unescape. So if we do both Marshalling and UnMarshalling, there would be no effect,t which is why it's working for the Transformer response. But here in the warehouse, the transformer would need to handle it separately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

While doing JSON marshalling, handle HTML Unicode characters. By default, during marshalling, SetEscapeHTML is true. During Unmarshalling, the library is already taking care of the unescape. So if we do both Marshalling and UnMarshalling, there would be no effect,t which is why it's working for the Transformer response. But here in the warehouse, the transformer would need to handle it separately.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am assuming that we are not doing any unmarshalling anywhere in warehouse, rt?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

New data formats keep popping up. And it would be difficult to maintain list of supported date time formats. Also, with the current logic of iterating to valid formats and finding the the valid one will become more expensive if the list grows too long. Moving to existing implementation of using dateparser.Any.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  // BenchmarkValidTimestamp
  // BenchmarkValidTimestamp/old_parser
  // BenchmarkValidTimestamp/old_parser-12         	    6999	    163017 ns/op
  // BenchmarkValidTimestamp/new_parser
  // BenchmarkValidTimestamp/new_parser-12         	   89427	     13392 ns/op

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Modify IsBlank for maps and slice of to be compatible with .isEmpty(.toString(value)).

// Corresponding lodash implementation: https://playcode.io/2371369
//
//	const isBlank = (value) => {
//	 try {
//	   return _.isEmpty(_.toString(value));
//	 } catch (e) {
//	   console.error(`Error in isBlank: ${e.message}`);
//	   return false;
//	 }
//	};

Comment thread warehouse/transformer/logger.go Outdated

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Currently, we are not handling such cases where 0001-01-01 00:00:00 converting to an invalid case in JavaScript resulting in 2001-01-01T00:00:00.000Z. https://www.programiz.com/online-compiler/4SqZcIH5k6Yli

Comment thread warehouse/transformer/events.go Resolved
Comment thread warehouse/transformer/events.go Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this change mean that RecordID being slice is not a valid event?

Comment thread warehouse/transformer/logger.go Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am assuming that we are not doing any unmarshalling anywhere in warehouse, rt?

@achettyiitr
achettyiitr requested a review from shekhar-rudder May 7, 2025 06:39
@achettyiitr
achettyiitr merged commit 1b1887e into release/1.48.x May 7, 2025
@achettyiitr
achettyiitr deleted the fix.warebhouse-transformations branch May 7, 2025 11:13
fracasula pushed a commit that referenced this pull request May 8, 2025
# Description

Syncing patch release v1.48.5 to main branch

**↓↓ Please review and edit commit overrides before merging ↓↓**

BEGIN_COMMIT_OVERRIDE
fix: warehouse transformations mismatches (#5779)
chore: update rudder-go-kit to 0.49.2 (#5832)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Aris Tzoumas <[email protected]>
Co-authored-by: Sudip Paul <[email protected]>
Co-authored-by: yeshwanth vuppu <[email protected]>
Co-authored-by: Akash Chetty <[email protected]>
satishrudderstack pushed a commit that referenced this pull request May 12, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.49.0-rc.1](v1.48.0...v1.49.0-rc.1)
(2025-05-12)


### Features

* add support for processing of upload_v2 job type by slave
([#5796](#5796))
([67988d1](67988d1))
* batch staging files for creating upload_v2 notifier jobs
([#5765](#5765))
([7dc3a45](7dc3a45))
* enable worker-based kafka client batching
([#5788](#5788))
([66dc19f](66dc19f))
* support claim renewal in notifier jobs
([#5818](#5818))
([a499d9c](a499d9c))
* support new consent resolution strategy values
([#5798](#5798))
([181b95b](181b95b))
* update config to add account details with destination in
workspaceConfig
([#5753](#5753))
([dbd46bf](dbd46bf))
* update contract for account and accountDefinition
([#5830](#5830))
([c704b07](c704b07))
* use account to decide oauth type of a destination
([#5810](#5810))
([9165e8c](9165e8c))


### Bug Fixes

* add check for nil secret on oauthv2
([#5807](#5807))
([fbc4abe](fbc4abe))
* convert bad request errors to 500 errors in oauth interceptor to
prevent panics
([#5813](#5813))
([3a08ec4](3a08ec4))
* **jobsdb:** completed datasets don't get deleted without a pair
([#5793](#5793))
([54aee71](54aee71))
* reporting common client path with query
([#5842](#5842))
([c068920](c068920))
* transformer client recycle ttl bound to connection idle timeout
([#5800](#5800))
([b13f92c](b13f92c))
* update account type to remove id which we are getting as map key
([#5835](#5835))
([bc52242](bc52242))
* ut mirroring race condition
([#5824](#5824))
([a4d579f](a4d579f))
* warehouse cached schema mismatch
([#5805](#5805))
([4656247](4656247))
* warehouse transformations mismatches
([#5779](#5779))
([01a7b83](01a7b83))


### Miscellaneous

* **deps:** bump github.com/snowflakedb/gosnowflake from 1.13.2 to
1.13.3 in the go_modules group
([#5787](#5787))
([41db33e](41db33e))
* **deps:** bump golangci/golangci-lint-action from 7 to 8
([#5815](#5815))
([bf3e808](bf3e808))
* **jobsdb:** cache distinct parameters query result for all datasets
except last
([#5752](#5752))
([e85811e](e85811e))
* migrate from denisenkom/go-mssqldb to microsoft/go-mssqldb
([#5776](#5776))
([dbd46bf](dbd46bf))
* revert synapse staging table with max varchar length
([#5817](#5817))
([2418329](2418329))
* **router:** support destination-specific configuration overrides for
all options
([#5841](#5841))
([695cf53](695cf53))
* synapse staging table with max varchar length
([#5775](#5775))
([2fc5384](2fc5384))
* update accountDefination type with authenticationType
([#5791](#5791))
([2a24e59](2a24e59))
* update rudder-go-kit to 0.49.2
([#5832](#5832))
([01a7b83](01a7b83))
* upload embedded dt response difference samples to s3
([#5792](#5792))
([c81001f](c81001f))
* warehouse transformer migration to embedded destination transformer
package
([#5827](#5827))
([e124bb0](e124bb0))
* warehouse transformer sample diff
([#5837](#5837))
([8af55de](8af55de))
* warehouse transformer uploader
([#5828](#5828))
([fc640bf](fc640bf))
* webhook integration test module upgrade
([#5665](#5665))
([f4130d1](f4130d1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
satishrudderstack pushed a commit that referenced this pull request May 13, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.49.0](v1.48.0...v1.49.0)
(2025-05-13)


### Features

* add dynamic config existence flag for destinations
([#5821](#5821))
([1b4ea06](1b4ea06))
* add support for processing of upload_v2 job type by slave
([#5796](#5796))
([67988d1](67988d1))
* batch staging files for creating upload_v2 notifier jobs
([#5765](#5765))
([7dc3a45](7dc3a45))
* enable worker-based kafka client batching
([#5788](#5788))
([66dc19f](66dc19f))
* support claim renewal in notifier jobs
([#5818](#5818))
([a499d9c](a499d9c))
* support new consent resolution strategy values
([#5798](#5798))
([181b95b](181b95b))
* update config to add account details with destination in
workspaceConfig
([#5753](#5753))
([dbd46bf](dbd46bf))
* update contract for account and accountDefinition
([#5830](#5830))
([c704b07](c704b07))
* use account to decide oauth type of a destination
([#5810](#5810))
([9165e8c](9165e8c))


### Bug Fixes

* add check for nil secret on oauthv2
([#5807](#5807))
([fbc4abe](fbc4abe))
* convert bad request errors to 500 errors in oauth interceptor to
prevent panics
([#5813](#5813))
([3a08ec4](3a08ec4))
* embedded transformations upload
([#5848](#5848))
([0b19968](0b19968))
* **jobsdb:** completed datasets don't get deleted without a pair
([#5793](#5793))
([54aee71](54aee71))
* reporting common client path with query
([#5842](#5842))
([c068920](c068920))
* transformer client recycle ttl bound to connection idle timeout
([#5800](#5800))
([b13f92c](b13f92c))
* update account type to remove id which we are getting as map key
([#5835](#5835))
([bc52242](bc52242))
* ut mirroring race condition
([#5824](#5824))
([a4d579f](a4d579f))
* warehouse cached schema mismatch
([#5805](#5805))
([4656247](4656247))
* warehouse transformations mismatches
([#5779](#5779))
([01a7b83](01a7b83))


### Miscellaneous

* **deps:** bump github.com/snowflakedb/gosnowflake from 1.13.2 to
1.13.3 in the go_modules group
([#5787](#5787))
([41db33e](41db33e))
* **deps:** bump golangci/golangci-lint-action from 7 to 8
([#5815](#5815))
([bf3e808](bf3e808))
* enrich event with bot details
([#5836](#5836))
([6035658](6035658))
* **jobsdb:** cache distinct parameters query result for all datasets
except last
([#5752](#5752))
([e85811e](e85811e))
* migrate from denisenkom/go-mssqldb to microsoft/go-mssqldb
([#5776](#5776))
([dbd46bf](dbd46bf))
* revert synapse staging table with max varchar length
([#5817](#5817))
([2418329](2418329))
* **router:** support destination-specific configuration overrides for
all options
([#5841](#5841))
([695cf53](695cf53))
* synapse staging table with max varchar length
([#5775](#5775))
([2fc5384](2fc5384))
* update accountDefination type with authenticationType
([#5791](#5791))
([2a24e59](2a24e59))
* update rudder-go-kit to 0.49.2
([#5832](#5832))
([01a7b83](01a7b83))
* upload embedded dt response difference samples to s3
([#5792](#5792))
([c81001f](c81001f))
* warehouse transformer migration to embedded destination transformer
package
([#5827](#5827))
([e124bb0](e124bb0))
* warehouse transformer sample diff
([#5837](#5837))
([8af55de](8af55de))
* warehouse transformer uploader
([#5828](#5828))
([fc640bf](fc640bf))
* webhook integration test module upgrade
([#5665](#5665))
([f4130d1](f4130d1))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants