Skip to content
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
6 changes: 3 additions & 3 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ jobs:
with:
ref: ${{ inputs.branch }}

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/integration-tests-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:
STOPPED_ENGINE_URL: ${{ steps.setup.outputs.stopped_engine_url }}
API_ENDPOINT: "api.staging.firebolt.io"
ACCOUNT_NAME: "firebolt"
LONG_TEST_VALUE: ${{ vars.LONG_TEST_VALUE_V1 }}
run: |
pytest --last-failed -n 6 --dist loadgroup --timeout_method "signal" -o log_cli=true -o log_cli_level=INFO tests/integration -k "not V2 and not core" --runslow

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/integration-tests-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
with:
repository: 'firebolt-db/firebolt-python-sdk'

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
Expand All @@ -56,6 +56,7 @@ jobs:
STOPPED_ENGINE_NAME: ${{ steps.setup.outputs.stopped_engine_name }}
API_ENDPOINT: "api.staging.firebolt.io"
ACCOUNT_NAME: ${{ vars.FIREBOLT_ACCOUNT }}
LONG_TEST_VALUE: ${{ vars.LONG_TEST_VALUE_V2 }}
run: |
pytest -n 6 --dist loadgroup --timeout_method "signal" -o log_cli=true -o log_cli_level=WARNING tests/integration -k "not V1 and not core" --runslow --alluredir=allure-results

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
max-parallel: 2
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -78,6 +78,7 @@ jobs:
STOPPED_ENGINE_URL: ${{ steps.setup.outputs.stopped_engine_url }}
ACCOUNT_NAME: "firebolt"
API_ENDPOINT: "api.staging.firebolt.io"
LONG_TEST_VALUE: ${{ vars.LONG_TEST_VALUE_V1 }}
run: |
pytest --timeout_method "thread" -o log_cli=true -o log_cli_level=WARNING --junit-xml=report/junit.xml tests/integration -k "not V2 and not core"

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nightly-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
max-parallel: 2
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Check out code
uses: actions/checkout@v2
Expand Down Expand Up @@ -74,6 +74,7 @@ jobs:
STOPPED_ENGINE_NAME: ${{ steps.setup.outputs.stopped_engine_name }}
ACCOUNT_NAME: ${{ vars.FIREBOLT_ACCOUNT }}
API_ENDPOINT: "api.staging.firebolt.io"
LONG_TEST_VALUE: ${{ vars.LONG_TEST_VALUE_V2 }}
run: |
pytest --timeout_method "thread" -o log_cli=true -o log_cli_level=WARNING --junit-xml=report/junit.xml tests/integration -k "not V1 and not core"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
with:
ref: ${{ inputs.branch }}

- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion docsrc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ executing queries using a library of Python classes and functions.
Prerequisites
========================

* Python version 3.8 or later along with the pip package installer. For more information,
* Python version 3.9 or later along with the pip package installer. For more information,
see the `Python <https://www.python.org/downloads/>`_ web page.

* A Firebolt account and login credentials.
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ classifiers =
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Expand All @@ -40,7 +39,7 @@ install_requires =
sqlparse>=0.4.2
trio>=0.22.0
truststore>=0.10;python_version>="3.10"
python_requires = >=3.8
python_requires = >=3.9
include_package_data = True
package_dir =
= src
Expand Down
8 changes: 6 additions & 2 deletions tests/integration/dbapi/async/V1/test_queries_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from firebolt.async_db import Binary, Connection, Cursor, OperationalError
from firebolt.common._types import ColType
from firebolt.common.row_set.types import Column
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V1

VALS_TO_INSERT_2 = ",".join(
[f"({i}, {i-3}, '{val}')" for (i, val) in enumerate(range(4, 1000))]
)
LONG_INSERT = f'INSERT INTO "test_tbl" VALUES {VALS_TO_INSERT_2}'
LONG_SELECT = (
"SELECT checksum(*) FROM GENERATE_SERIES(1, 250000000000)" # approx 6m runtime
"SELECT checksum(*) FROM GENERATE_SERIES(1, {long_value})" # approx 6m runtime
)

CREATE_EXTERNAL_TABLE = """CREATE EXTERNAL TABLE IF NOT EXISTS "ex_lineitem" (
Expand Down Expand Up @@ -174,14 +175,17 @@ async def test_select_nan(connection: Connection) -> None:
async def test_long_query(
connection: Connection,
minimal_time: Callable[[float], None],
long_test_value: int,
) -> None:
"""AWS ALB TCP timeout set to 350; make sure we handle the keepalive correctly."""

# Fail test if it takes less than 350 seconds
minimal_time(350)

async with connection.cursor() as c:
await c.execute(LONG_SELECT)
await c.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V1))
)
data = await c.fetchall()
assert len(data) == 1, "Invalid data size returned by fetchall"

Expand Down
14 changes: 9 additions & 5 deletions tests/integration/dbapi/async/V2/test_queries_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
from firebolt.common._types import ColType
from firebolt.common.row_set.types import Column
from firebolt.utils.exception import FireboltStructuredError
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V2
from tests.integration.dbapi.utils import assert_deep_eq

VALS_TO_INSERT_2 = ",".join(
[f"({i}, {i-3}, '{val}')" for (i, val) in enumerate(range(4, 1000))]
)
LONG_INSERT = f'INSERT INTO "test_tbl" VALUES {VALS_TO_INSERT_2}'
LONG_SELECT = (
"SELECT checksum(*) FROM GENERATE_SERIES(1, 400000000000)" # approx 6m runtime
"SELECT checksum(*) FROM GENERATE_SERIES(1, {long_value})" # approx 6m runtime
)


Expand Down Expand Up @@ -102,13 +103,16 @@ async def test_select_nan(connection: Connection) -> None:
async def test_long_query(
connection: Connection,
minimal_time: Callable[[float], None],
long_test_value: Callable[[int], int],
) -> None:
"""AWS ALB TCP timeout set to 350; make sure we handle the keepalive correctly."""

minimal_time(350)

async with connection.cursor() as c:
await c.execute(LONG_SELECT)
await c.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V2))
)
data = await c.fetchall()
assert len(data) == 1, "Invalid data size returned by fetchall"

Expand Down Expand Up @@ -265,16 +269,16 @@ async def test_empty_query(c: Cursor, query: str, params: tuple) -> None:
async def test_parameterized_query_with_special_chars(connection: Connection) -> None:
"""Query parameters are handled properly."""
async with connection.cursor() as c:
params = ["text with 'quote'", "text with \\slashes"]
parameters = ["text with 'quote'", "text with \\slashes"]

await c.execute(
"SELECT ? as one, ? as two",
params,
parameters,
)

result = await c.fetchall()
assert result == [
[params[0], params[1]]
[parameters[0], parameters[1]]
], "Invalid data in table after parameterized insert"


Expand Down
12 changes: 10 additions & 2 deletions tests/integration/dbapi/async/V2/test_timeout.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
from typing import Callable

from pytest import raises

from firebolt.async_db import Connection
from firebolt.utils.exception import QueryTimeoutError
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V2

# Cannot have absolute path here since interpreter treats word async as keyword and not as a package name
from .test_queries_async import LONG_SELECT


async def test_query_timeout(connection: Connection):
async def test_query_timeout(
connection: Connection, long_test_value: Callable[[int], int]
) -> None:
async with connection.cursor() as cursor:
with raises(QueryTimeoutError):
await cursor.execute(LONG_SELECT, timeout_seconds=1)
await cursor.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V2)),
timeout_seconds=1,
)
14 changes: 14 additions & 0 deletions tests/integration/dbapi/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
from logging import getLogger
Expand All @@ -16,6 +17,19 @@
)
DROP_TEST_TABLE = 'DROP TABLE IF EXISTS "test_tbl" CASCADE'

LONG_SELECT_DEFAULT_V1 = 250000000000
LONG_SELECT_DEFAULT_V2 = 350000000000


@fixture
def long_test_value() -> int:
"""Return the long test value from environment variable or 0 to use default."""

def long_test_value_with_default(default: int = 0) -> int:
return int(os.getenv("LONG_TEST_VALUE", default))

return long_test_value_with_default


@fixture
def create_drop_test_table_setup_teardown(connection: Connection) -> None:
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/dbapi/sync/V1/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from firebolt.common._types import ColType
from firebolt.common.row_set.types import Column
from firebolt.db import Binary, Connection, Cursor, OperationalError, connect
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V1

VALS_TO_INSERT = ",".join([f"({i},'{val}')" for (i, val) in enumerate(range(1, 360))])
LONG_INSERT = f'INSERT INTO "test_tbl" VALUES {VALS_TO_INSERT}'
LONG_SELECT = (
"SELECT checksum(*) FROM GENERATE_SERIES(1, 250000000000)" # approx 6m runtime
"SELECT checksum(*) FROM GENERATE_SERIES(1, {long_value})" # approx 6m runtime
)


Expand Down Expand Up @@ -122,15 +123,19 @@ def test_select_nan(connection: Connection) -> None:
@mark.slow
@mark.timeout(timeout=1000)
def test_long_query(
connection: Connection, minimal_time: Callable[[float], None]
connection: Connection,
minimal_time: Callable[[float], None],
long_test_value: Callable[[int], int],
) -> None:
"""AWS ALB TCP timeout set to 350, make sure we handle the keepalive correctly."""

# Fail test if it takes less than 350 seconds
minimal_time(350)

with connection.cursor() as c:
c.execute(LONG_SELECT)
c.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V1))
)
data = c.fetchall()
assert len(data) == 1, "Invalid data size returned by fetchall"

Expand Down
14 changes: 9 additions & 5 deletions tests/integration/dbapi/sync/V2/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
from firebolt.common.row_set.types import Column
from firebolt.db import Binary, Connection, Cursor, OperationalError, connect
from firebolt.utils.exception import FireboltStructuredError
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V2
from tests.integration.dbapi.utils import assert_deep_eq

VALS_TO_INSERT = ",".join([f"({i},'{val}')" for (i, val) in enumerate(range(1, 360))])
LONG_INSERT = f"INSERT INTO test_tbl VALUES {VALS_TO_INSERT}"
LONG_SELECT = (
"SELECT checksum(*) FROM GENERATE_SERIES(1, 400000000000)" # approx 6m runtime
"SELECT checksum(*) FROM GENERATE_SERIES(1, {long_value})" # approx 6m runtime
)


Expand Down Expand Up @@ -106,13 +107,16 @@ def test_select_nan(connection: Connection) -> None:
def test_long_query(
connection: Connection,
minimal_time: Callable[[float], None],
long_test_value: Callable[[int], int],
) -> None:
"""AWS ALB TCP timeout set to 350; make sure we handle the keepalive correctly."""

minimal_time(350)

with connection.cursor() as c:
c.execute(LONG_SELECT)
c.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V2))
)
data = c.fetchall()
assert len(data) == 1, "Invalid data size returned by fetchall"

Expand Down Expand Up @@ -214,16 +218,16 @@ def test_empty_query(c: Cursor, query: str) -> None:
def test_parameterized_query_with_special_chars(connection: Connection) -> None:
"""Query parameters are handled properly."""
with connection.cursor() as c:
params = ["text with 'quote'", "text with \\slashes"]
parameters = ["text with 'quote'", "text with \\slashes"]

c.execute(
"SELECT ? as one, ? as two",
params,
parameters,
)

result = c.fetchall()
assert result == [
[params[0], params[1]]
[parameters[0], parameters[1]]
], "Invalid data in table after parameterized insert"


Expand Down
12 changes: 10 additions & 2 deletions tests/integration/dbapi/sync/V2/test_timeout.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
from typing import Callable

from pytest import raises

from firebolt.db import Connection
from firebolt.utils.exception import QueryTimeoutError
from tests.integration.dbapi.conftest import LONG_SELECT_DEFAULT_V2

from .test_queries import LONG_SELECT


def test_query_timeout(connection: Connection):
def test_query_timeout(
connection: Connection, long_test_value: Callable[[int], int]
) -> None:
with connection.cursor() as cursor:
with raises(QueryTimeoutError):
cursor.execute(LONG_SELECT, timeout_seconds=1)
cursor.execute(
LONG_SELECT.format(long_value=long_test_value(LONG_SELECT_DEFAULT_V2)),
timeout_seconds=1,
)
Loading