%%sql --module MyModule
DEFINE QUERY q1
WITH MyTempTable AS
(
SELECT 'Datalab' AS Name
)
SELECT * FROM MyTempTable
SELECT * FROM $q1
import datalab.bigquery as bq
bq.Query(MyModule.q1).results(dialect='standard')
ExceptionTraceback (most recent call last)
<ipython-input-5-e39df25b5c74> in <module>()
1 import datalab.bigquery as bq
----> 2 bq.Query(MyModule.q1).results(dialect='standard')
/usr/local/lib/python2.7/dist-packages/datalab/bigquery/_query.pyc in results(self, use_cache, dialect, billing_tier)
226 """
227 if not use_cache or (self._results is None):
--> 228 self.execute(use_cache=use_cache, dialect=dialect, billing_tier=billing_tier)
229 return self._results.results
230
/usr/local/lib/python2.7/dist-packages/datalab/bigquery/_query.pyc in execute(self, table_name, table_mode, use_cache, priority, allow_large_results, dialect, billing_tier)
524 job = self.execute_async(table_name=table_name, table_mode=table_mode, use_cache=use_cache,
525 priority=priority, allow_large_results=allow_large_results,
--> 526 dialect=dialect, billing_tier=billing_tier)
527 self._results = job.wait()
528 return self._results
/usr/local/lib/python2.7/dist-packages/datalab/bigquery/_query.pyc in execute_async(self, table_name, table_mode, use_cache, priority, allow_large_results, dialect, billing_tier)
490 except KeyError:
491 # The query was in error
--> 492 raise Exception(_utils.format_query_errors(query_result['status']['errors']))
493 return _query_job.QueryJob(job_id, table_name, self._sql, context=self._context)
494
Exception: invalidQuery: Syntax error: Unexpected end of statement at [1:1]
%%sql --module MyModule
DEFINE QUERY q1
SELECT 'Datalab' AS Name
SELECT * FROM $q1
import datalab.bigquery as bq
bq.Query(MyModule.q1).results(dialect='standard')
I'm working on a PR to correct this issue.