Skip to content

Commit

Permalink
Apply import ordering in ruff check
Browse files Browse the repository at this point in the history
  • Loading branch information
timsaucer committed Jan 20, 2025
1 parent 31fee39 commit 5fa591f
Show file tree
Hide file tree
Showing 69 changed files with 221 additions and 189 deletions.
12 changes: 7 additions & 5 deletions benchmarks/db-benchmark/groupby-datafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@
# specific language governing permissions and limitations
# under the License.

import os
import gc
import os
import timeit

import datafusion as df
import pyarrow
from datafusion import (
col,
functions as f,
RuntimeEnvBuilder,
SessionConfig,
SessionContext,
col,
)
from datafusion import (
functions as f,
)
import pyarrow
from pyarrow import csv as pacsv


print("# groupby-datafusion.py", flush=True)

exec(open("./_helpers/helpers.py").read())
Expand Down
6 changes: 3 additions & 3 deletions benchmarks/db-benchmark/join-datafusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
# specific language governing permissions and limitations
# under the License.

import os
import gc
import os
import timeit

import datafusion as df
from datafusion import functions as f
from datafusion import col
from datafusion import functions as f
from pyarrow import csv as pacsv


print("# join-datafusion.py", flush=True)

exec(open("./_helpers/helpers.py").read())
Expand Down
3 changes: 2 additions & 1 deletion benchmarks/tpch/tpch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
# under the License.

import argparse
from datafusion import SessionContext
import time

from datafusion import SessionContext


def bench(data_path, query_path):
with open("results.csv", "w") as results:
Expand Down
5 changes: 3 additions & 2 deletions dev/release/generate-changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
# limitations under the License.

import argparse
import sys
from github import Github
import os
import re
import subprocess
import sys

from github import Github


def print_pulls(repo_name, title, pulls):
Expand Down
1 change: 0 additions & 1 deletion examples/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import datafusion


# create a context
ctx = datafusion.SessionContext()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.

import pyarrow as pa
from datafusion import SessionContext
from ffi_table_provider import MyTableProvider
import pyarrow as pa


def test_table_loading():
Expand Down
3 changes: 1 addition & 2 deletions examples/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
# under the License.

import datafusion
import pyarrow as pa
import pandas as pd
import polars as pl

import pyarrow as pa

# Create a context
ctx = datafusion.SessionContext()
Expand Down
5 changes: 2 additions & 3 deletions examples/python-udaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
# specific language governing permissions and limitations
# under the License.

import datafusion
import pyarrow
import pyarrow.compute
import datafusion
from datafusion import udaf, Accumulator
from datafusion import col
from datafusion import Accumulator, col, udaf


class MyAccumulator(Accumulator):
Expand Down
6 changes: 4 additions & 2 deletions examples/python-udf-comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
# specific language governing permissions and limitations
# under the License.

from datafusion import SessionContext, col, lit, udf, functions as F
import os
import time

import pyarrow as pa
import pyarrow.compute as pc
import time
from datafusion import SessionContext, col, lit, udf
from datafusion import functions as F

path = os.path.dirname(os.path.abspath(__file__))
filepath = os.path.join(path, "./tpch/data/lineitem.parquet")
Expand Down
3 changes: 2 additions & 1 deletion examples/python-udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# under the License.

import pyarrow
from datafusion import udf, SessionContext, functions as f
from datafusion import SessionContext, udf
from datafusion import functions as f


def is_null(array: pyarrow.Array) -> pyarrow.Array:
Expand Down
7 changes: 4 additions & 3 deletions examples/python-udwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# specific language governing permissions and limitations
# under the License.

import pyarrow as pa
import datafusion
from datafusion import udwf, functions as f, col, lit
from datafusion.udf import WindowEvaluator
import pyarrow as pa
from datafusion import col, lit, udwf
from datafusion import functions as f
from datafusion.expr import WindowFrame
from datafusion.udf import WindowEvaluator

# This example creates five different examples of user defined window functions in order
# to demonstrate the variety of ways a user may need to implement.
Expand Down
3 changes: 1 addition & 2 deletions examples/query-pyarrow-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
# under the License.

import datafusion
from datafusion import col
import pyarrow

from datafusion import col

# create a context
ctx = datafusion.SessionContext()
Expand Down
1 change: 1 addition & 0 deletions examples/sql-parquet-s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# under the License.

import os

import datafusion
from datafusion.object_store import AmazonS3

Expand Down
1 change: 0 additions & 1 deletion examples/sql-to-pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from datafusion import SessionContext


# Create a DataFusion context
ctx = SessionContext()

Expand Down
2 changes: 1 addition & 1 deletion examples/sql-using-python-udaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.

from datafusion import udaf, SessionContext, Accumulator
import pyarrow as pa
from datafusion import Accumulator, SessionContext, udaf


# Define a user-defined aggregation function (UDAF)
Expand Down
2 changes: 1 addition & 1 deletion examples/sql-using-python-udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.

from datafusion import udf, SessionContext
import pyarrow as pa
from datafusion import SessionContext, udf


# Define a user-defined function (UDF)
Expand Down
6 changes: 4 additions & 2 deletions examples/tpch/_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
# specific language governing permissions and limitations
# under the License.

import pytest
from importlib import import_module

import pyarrow as pa
from datafusion import DataFrame, col, lit, functions as F
import pytest
from datafusion import DataFrame, col, lit
from datafusion import functions as F
from util import get_answer_file


Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/convert_data_to_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"""

import os
import pyarrow

import datafusion
import pyarrow

ctx = datafusion.SessionContext()

Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q01_pricing_summary_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"""

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

ctx = SessionContext()
Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q02_minimum_cost_supplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"""

import datafusion
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

# This is the part we're looking for. Values selected here differ from the spec in order to run
Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q03_shipping_priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
as part of their TPC Benchmark H Specification revision 2.18.0.
"""

from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

SEGMENT_OF_INTEREST = "BUILDING"
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q04_order_priority_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

# Ideally we could put 3 months into the interval. See note below.
Expand Down
5 changes: 3 additions & 2 deletions examples/tpch/q05_local_supplier_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path


DATE_OF_INTEREST = "1994-01-01"
INTERVAL_DAYS = 365
REGION_OF_INTEREST = "ASIA"
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q06_forecasting_revenue_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

# Variables from the example query
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q07_volume_shipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

# Variables of interest to query over
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q08_market_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

supplier_nation = lit("BRAZIL")
Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q09_product_type_profit_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"""

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

part_color = lit("green")
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q10_returned_item_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

DATE_START_OF_QUARTER = "1993-10-01"
Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q11_important_stock_identification.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
as part of their TPC Benchmark H Specification revision 2.18.0.
"""

from datafusion import SessionContext, WindowFrame, col, lit, functions as F
from datafusion import SessionContext, WindowFrame, col, lit
from datafusion import functions as F
from util import get_data_path

NATION = "GERMANY"
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q12_ship_mode_order_priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

SHIP_MODE_1 = "MAIL"
Expand Down
3 changes: 2 additions & 1 deletion examples/tpch/q13_customer_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
as part of their TPC Benchmark H Specification revision 2.18.0.
"""

from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

WORD_1 = "special"
Expand Down
4 changes: 3 additions & 1 deletion examples/tpch/q14_promotion_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
"""

from datetime import datetime

import pyarrow as pa
from datafusion import SessionContext, col, lit, functions as F
from datafusion import SessionContext, col, lit
from datafusion import functions as F
from util import get_data_path

DATE = "1995-09-01"
Expand Down
Loading

0 comments on commit 5fa591f

Please sign in to comment.