Skip to content

Commit 240d44a

Browse files
committed
Add system tests for standard SQL scalar column types.
1 parent 175e027 commit 240d44a

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

system_tests/bigquery.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,49 @@ def _job_done(instance):
479479
# raise an error, and that the job completed (in the `retry()`
480480
# above).
481481

482-
def test_sync_query_w_nested_arrays_and_structs(self):
482+
def test_sync_query_w_standard_sql_types(self):
483+
import datetime
484+
from google.cloud._helpers import UTC
485+
naive = datetime.datetime(2016, 12, 5, 12, 41, 9)
486+
stamp = "%s %s" %(naive.date().isoformat(), naive.time().isoformat())
487+
zoned = naive.replace(tzinfo=UTC)
483488
EXAMPLES = [
484489
{
485490
'sql': 'SELECT 1',
486491
'expected': 1,
487492
},
493+
{
494+
'sql': 'SELECT 1.3',
495+
'expected': 1.3,
496+
},
497+
{
498+
'sql': 'SELECT TRUE',
499+
'expected': True,
500+
},
501+
{
502+
'sql': 'SELECT "ABC"',
503+
'expected': 'ABC',
504+
},
505+
{
506+
'sql': 'SELECT CAST("foo" AS BYTES)',
507+
'expected': b'foo',
508+
},
509+
{
510+
'sql': 'SELECT TIMESTAMP "%s"' % (stamp,),
511+
'expected': zoned,
512+
},
513+
{
514+
'sql': 'SELECT DATETIME(TIMESTAMP "%s")' % (stamp,),
515+
'expected': naive,
516+
},
517+
{
518+
'sql': 'SELECT DATE(TIMESTAMP "%s")' % (stamp,),
519+
'expected': naive.date(),
520+
},
521+
{
522+
'sql': 'SELECT TIME(TIMESTAMP "%s")' % (stamp,),
523+
'expected': naive.time(),
524+
},
488525
{
489526
'sql': 'SELECT (1, 2)',
490527
'expected': {'_field_1': 1, '_field_2': 2},

0 commit comments

Comments
 (0)