@@ -77,6 +77,25 @@ def _get_metadata_column_names(self) -> List[str]:
7777 if self .conn_config .get ("fast_sync_rds_add_metadata_columns" , True ):
7878 return METADATA_COLUMNS
7979 return []
80+
81+ def _get_fast_sync_rds_transformation (self , tap_stream_id : str ) -> Dict [str , str ]:
82+ return self .conn_config .get ("fast_sync_rds_transformations" , {}).get (
83+ tap_stream_id , {}
84+ )
85+
86+ def _get_extra_column_properties (
87+ self , desired_columns : List [str ], stream : Dict
88+ ) -> List [str ]:
89+ transformation_columns = self ._get_fast_sync_rds_transformation (
90+ stream ["tap_stream_id" ]
91+ )
92+ all_columns = {* self ._get_metadata_column_names (), * desired_columns }
93+ extra_columns = [
94+ col for col in transformation_columns if col not in all_columns
95+ ]
96+
97+ # On-the-fly columns use string type; other types could be added if needed.
98+ return {col : {"type" : ["string" , "null" ]} for col in extra_columns }
8099
81100 def _get_metadata_column_sql (self , column_name : str ) -> str :
82101 """Get SQL expression for a metadata column."""
@@ -155,12 +174,7 @@ def _build_sorted_column_expressions(
155174 all_column_names .sort ()
156175
157176 # Get transformations for this stream if available
158- transformations = {}
159- if tap_stream_id :
160- all_transformations = self .conn_config .get (
161- "fast_sync_rds_transformations" , {}
162- )
163- transformations = all_transformations .get (tap_stream_id , {})
177+ transformations = self ._get_fast_sync_rds_transformation (tap_stream_id )
164178
165179 column_expressions = []
166180 for name in all_column_names :
@@ -380,6 +394,30 @@ def _track_latest_replication_key_value( # pylint: disable=invalid-name,too-man
380394
381395 return state
382396
397+ def prepare_stream_with_extra_columns (
398+ self , desired_columns : List [str ], stream : Dict
399+ ):
400+ """
401+ Prepare stream with extra columns for fast sync RDS strategy.
402+ Extra columns are columns that are created on the fly (not in orginal catalog)
403+ provided by fast_sync_rds_transformations configuration.
404+ To make it simple, their type is always ["string", "null"].
405+
406+ Args:
407+ desired_columns: List of desired column names from the source table
408+ stream: Stream dictionary
409+
410+ Returns:
411+ List of desired column names with extra columns
412+ """
413+ extra_columns_properties = self ._get_extra_column_properties (
414+ desired_columns , stream
415+ )
416+ stream ["schema" ]["properties" ].update (extra_columns_properties )
417+ desired_columns .extend (extra_columns_properties .keys ())
418+ desired_columns .sort ()
419+ return desired_columns
420+
383421 def sync_table ( # pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals
384422 self ,
385423 stream : Dict ,
0 commit comments