Skip to content

Commit

Permalink
fix: update csv parser for builder compatibility (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristoGrab authored Feb 21, 2025
1 parent 665dc1f commit c3efa4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def parse(
"""
text_data = TextIOWrapper(data, encoding=self.encoding) # type: ignore
reader = csv.DictReader(text_data, delimiter=self._get_delimiter() or ",")
yield from reader
for row in reader:
yield row


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2091,10 +2091,10 @@ def create_dynamic_schema_loader(
def create_json_decoder(model: JsonDecoderModel, config: Config, **kwargs: Any) -> Decoder:
return JsonDecoder(parameters={})

@staticmethod
def create_csv_decoder(model: CsvDecoderModel, config: Config, **kwargs: Any) -> Decoder:
def create_csv_decoder(self, model: CsvDecoderModel, config: Config, **kwargs: Any) -> Decoder:
return CompositeRawDecoder(
parser=ModelToComponentFactory._get_parser(model, config), stream_response=True
parser=ModelToComponentFactory._get_parser(model, config),
stream_response=False if self._emit_connector_builder_messages else True,
)

@staticmethod
Expand All @@ -2103,10 +2103,12 @@ def create_jsonl_decoder(model: JsonlDecoderModel, config: Config, **kwargs: Any
parser=ModelToComponentFactory._get_parser(model, config), stream_response=True
)

@staticmethod
def create_gzip_decoder(model: GzipDecoderModel, config: Config, **kwargs: Any) -> Decoder:
def create_gzip_decoder(
self, model: GzipDecoderModel, config: Config, **kwargs: Any
) -> Decoder:
return CompositeRawDecoder(
parser=ModelToComponentFactory._get_parser(model, config), stream_response=True
parser=ModelToComponentFactory._get_parser(model, config),
stream_response=False if self._emit_connector_builder_messages else True,
)

@staticmethod
Expand Down

0 comments on commit c3efa4c

Please sign in to comment.