-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf2b4c6
commit 5ae4838
Showing
55 changed files
with
15,412 additions
and
8 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package transformer | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/samber/lo" | ||
|
||
"github.com/rudderlabs/rudder-server/warehouse/transformer/internal/rules" | ||
) | ||
|
||
func (t *transformer) handleAliasEvent(pi *processingInfo) ([]map[string]any, error) { | ||
aliasEvent := make(map[string]any) | ||
columnTypes := make(map[string]string) | ||
|
||
if err := t.setDataAndColumnTypeFromInput(pi, pi.event.Message["traits"], aliasEvent, columnTypes, | ||
"alias_traits_", 2, "", 0, | ||
); err != nil { | ||
return nil, fmt.Errorf("setting data and column types from message: %w", err) | ||
} | ||
if err := t.setDataAndColumnTypeFromInput(pi, pi.event.Message["context"], aliasEvent, columnTypes, | ||
"alias_context_", 2, "context_", 0, | ||
); err != nil { | ||
return nil, fmt.Errorf("setting data and column types from message: %w", err) | ||
} | ||
if err := t.setDataAndColumnTypeFromRules(pi, aliasEvent, columnTypes, | ||
lo.Assign(rules.DefaultRules, rules.AliasRules), rules.DefaultFunctionalRules, | ||
); err != nil { | ||
return nil, fmt.Errorf("setting data and column types from rules: %w", err) | ||
} | ||
if err := storeRudderEvent(pi, aliasEvent, columnTypes); err != nil { | ||
return nil, fmt.Errorf("storing rudder event: %w", err) | ||
} | ||
|
||
table, err := SafeTableName(pi.event.Metadata.DestinationType, pi.itrOpts, "aliases") | ||
if err != nil { | ||
return nil, fmt.Errorf("safe table name: %w", err) | ||
} | ||
columns, err := t.getColumns(pi.event.Metadata.DestinationType, aliasEvent, columnTypes) | ||
if err != nil { | ||
return nil, fmt.Errorf("getting columns: %w", err) | ||
} | ||
|
||
mergeEvents, err := t.handleMergeEvent(pi) | ||
if err != nil { | ||
return nil, fmt.Errorf("handling merge event: %w", err) | ||
} | ||
|
||
aliasOutput := map[string]any{ | ||
"data": aliasEvent, | ||
"metadata": map[string]any{ | ||
"table": table, | ||
"columns": columns, | ||
"receivedAt": pi.event.Metadata.ReceivedAt, | ||
}, | ||
"userId": "", | ||
} | ||
return append([]map[string]any{aliasOutput}, mergeEvents...), nil | ||
} |
Oops, something went wrong.