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

[BUGFIX] 144-BOX-CSVREADER #145

Merged
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
7 changes: 3 additions & 4 deletions src/koheesio/integrations/box.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
model_validator,
)
from koheesio.spark.readers import Reader
from koheesio.spark.readers.memory import InMemoryDataReader
from koheesio.utils import utc_now


Expand Down Expand Up @@ -418,10 +419,8 @@ def execute(self) -> BoxReaderBase.Output:
file = self.client.file(file_id=f)
data = file.content().decode(self.file_encoding)

data_buffer = StringIO(data)
temp_df_pandas = pd.read_csv(data_buffer, header=0, dtype=str if not self.schema_ else None, **self.params) # type: ignore
temp_df = self.spark.createDataFrame(temp_df_pandas, schema=self.schema_)

temp_df = InMemoryDataReader(data=data, schema=self.schema_, params=self.params, format="csv").read()

# type: ignore
# noinspection PyUnresolvedReferences
temp_df = (
Expand Down
2 changes: 1 addition & 1 deletion tests/spark/integrations/box/test_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_execute_wo_schema(self, spark, dummy_box):
assert bcr.df.count() == 1
assert bcr.df.dtypes == [
("foo", "string"),
("bar", "string"),
("bar", "bigint"),
("meta_file_id", "string"),
("meta_file_name", "string"),
("meta_load_timestamp", "timestamp"),
Expand Down
Loading