Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendBraeckmans committed Jun 5, 2024
1 parent 5b3037d commit a48d0f4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/koheesio/integrations/spark/dq/spark_expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

from typing import Any, Dict, Optional, Union

import pyspark
from pydantic import Field
from pyspark.sql import DataFrame
from spark_expectations.config.user_config import Constants as user_config
from spark_expectations.core.expectations import (
SparkExpectations,
WrappedDataFrameWriter,
)

from pydantic import Field

import pyspark
from pyspark.sql import DataFrame

from koheesio.spark.transformations import Transformation
from koheesio.spark.writers import BatchOutputMode

Expand Down
7 changes: 3 additions & 4 deletions src/koheesio/spark/readers/databricks/autoloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
Autoloader can ingest JSON, CSV, PARQUET, AVRO, ORC, TEXT, and BINARYFILE file formats.
"""

from enum import Enum
from typing import Dict, Optional, Union

import json
from typing import Dict, Optional, Union
from enum import Enum
from pathlib import Path

from pyspark.sql.types import StructType
from pyspark.sql.streaming import DataStreamReader
from pyspark.sql.types import StructType

from koheesio.models import Field, field_validator
from koheesio.spark.readers import Reader
Expand Down
6 changes: 4 additions & 2 deletions tests/spark/integrations/dq/test_spark_expectations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import List, Union

import pyspark
import pytest
from koheesio.utils import get_project_root

import pyspark
from pyspark.sql import SparkSession

from koheesio.utils import get_project_root

PROJECT_ROOT = get_project_root()

pytestmark = pytest.mark.spark
Expand Down
7 changes: 5 additions & 2 deletions tests/spark/readers/test_auto_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_read_json(spark, mocker, data_path):
expected_df = spark.createDataFrame(data_expected, schema_expected)
assert_df_equality(result, expected_df, ignore_column_order=True)


def test_read_json_schema_defined(spark, mocker, data_path):
mocker.patch("koheesio.spark.readers.databricks.autoloader.AutoLoader.reader", mock_reader)

Expand All @@ -62,7 +63,9 @@ def test_read_json_schema_defined(spark, mocker, data_path):
)
options = {"multiLine": "true"}
json_file_path_str = f"{data_path}/readers/json_file/dummy.json"
auto_loader = AutoLoader(format="json", location=json_file_path_str, schema_location="dummy_value", options=options, schema=schema)
auto_loader = AutoLoader(
format="json", location=json_file_path_str, schema_location="dummy_value", options=options, schema=schema
)

auto_loader.execute()
result = auto_loader.output.df
Expand All @@ -72,4 +75,4 @@ def test_read_json_schema_defined(spark, mocker, data_path):
{"string": "string2", "int": 2, "array": [2, 22, 222]},
]
expected_df = spark.createDataFrame(data_expected, schema)
assert_df_equality(result, expected_df, ignore_column_order=True)
assert_df_equality(result, expected_df, ignore_column_order=True)
7 changes: 5 additions & 2 deletions tests/spark/writers/delta/test_delta_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import pytest
from conftest import await_job_completion
from delta import DeltaTable

from pydantic import ValidationError

from pyspark.sql import functions as F

from koheesio.spark import AnalysisException
from koheesio.spark.delta import DeltaTableStep
from koheesio.spark.writers import BatchOutputMode, StreamingOutputMode
from koheesio.spark.writers.delta import DeltaTableStreamWriter, DeltaTableWriter
from koheesio.spark.writers.delta.utils import log_clauses
from koheesio.spark.writers.stream import Trigger
from pydantic import ValidationError
from pyspark.sql import functions as F

pytestmark = pytest.mark.spark

Expand Down

0 comments on commit a48d0f4

Please sign in to comment.