Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xando committed Jun 12, 2024
1 parent bbf1ef5 commit 47854a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/pyarrow/bigquery/write/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def _bq_create_table(*, project, location, schema, expire, overwrite):

client.create_table(table)

print(client.get_table(location))

if expire:
table.expires = datetime.datetime.now() + datetime.timedelta(seconds=expire)
client.update_table(table, ["expires"])
Expand Down
19 changes: 11 additions & 8 deletions tests/integration/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@
import pyarrow as pa
import pyarrow.bigquery as bq

print(os.environ)

PROJECT = os.environ['GCP_PROJECT']
LOCATION = f"{PROJECT}.test.{uuid.uuid4()}"


@pytest.fixture(autouse=True)
def _remove_table():
@pytest.fixture(scope="function")
def LOCATION():
return f"{PROJECT}.test.{uuid.uuid4()}"


@pytest.fixture(autouse=True, scope='function')
def _remove_table(LOCATION):
from google.cloud import bigquery

bigquery.Client(project="xando-1-main").delete_table(LOCATION, not_found_ok=True)
yield
bigquery.Client(project="xando-1-main").delete_table(LOCATION, not_found_ok=True)


def test_simple():
def test_simple(LOCATION):
table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"])

bq.write_table(table, LOCATION, table_create=True)
Expand All @@ -31,7 +34,7 @@ def test_simple():
assert table_back.sort_by("test").equals(table.sort_by("test"))


def test_reader_query():
def test_reader_query(LOCATION):
table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"])

bq.write_table(table, LOCATION, table_create=True)
Expand All @@ -47,7 +50,7 @@ def test_reader_query():
assert table_back2.sort_by("test").equals(table.sort_by("test"))


def test_context():
def test_context(LOCATION):
table = pa.Table.from_arrays([[1, 2, 3, 4]], names=["test"])

with bq.writer(table.schema, LOCATION, table_create=True) as w:
Expand All @@ -59,7 +62,7 @@ def test_context():
assert table_back.sort_by("test").equals(table.sort_by("test"))


def test_complex():
def test_complex(LOCATION):
_1d_int = pa.array([1, 2])
_2d_int = pa.array([[1, 2, 3], [4, 5, 6]])
_3d_int = pa.array(
Expand Down

0 comments on commit 47854a2

Please sign in to comment.