GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-bigquery/tests/system/test_structs.py at main · bmwant/python-bigquery

Expand file tree

/

test_structs.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
32 lines (26 loc) · 998 Bytes
/

test_structs.py

Copy path

File metadata and controls

32 lines (26 loc) · 998 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import datetime
import pytest
from google.cloud.bigquery.dbapi import connect
person_type = "struct<name string," " children array<struct<name string, bdate date>>>"
person_type_sized = (
"struct<name string(22)," " children array<struct<name string(22), bdate date>>>"
)
@pytest.mark.parametrize("person_type_decl", [person_type, person_type_sized])
def test_structs(bigquery_client, dataset_id, person_type_decl, table_id):
conn = connect(bigquery_client)
cursor = conn.cursor()
cursor.execute(f"create table {table_id} (person {person_type_decl})")
data = dict(
name="par",
children=[
dict(name="ch1", bdate=datetime.date(2021, 1, 1)),
dict(name="ch2", bdate=datetime.date(2021, 1, 2)),
],
)
cursor.execute(
f"insert into {table_id} (person) values (%(v:{person_type})s)",
dict(v=data),
)
cursor.execute(f"select * from {table_id}")
[[result]] = list(cursor)
assert result == data
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.