読譜活動 – ZetaSQL – execute_query

朝起きるとコンパイラが死んでいた。昼休みにちょこちょことなんとかする試み。

  • メモリが足りないのでしょう、ということで wsl.config で 6GB だったキャップを 12GB に拡大したところビルドは成功。メモリ買うかな・・・。
  • execute_query のバイナリができたので README にあるとおり execute_query “select 1 + 1” を実行したら、なにかが返ってきた。
$ bazel-bin/zetasql/tools/execute_query/execute_query "select 1 + 1"
+---+
|   |
+---+
| 2 |
+---+
  • execute_query –helpfull をするといろいろフラグがある。最近の ABSL flags はフラグを定義しているファイル名が表示されるようになっており、ちょっと便利。 
$ bazel-bin/zetasql/tools/execute_query/execute_query --mode=explain "select 1 + 1"
RootOp(
+-input: ComputeOp(
  +-map: {
  | +-$col1 := Add(ConstExpr(1), ConstExpr(1))},
  +-input: EnumerateOp(ConstExpr(1))))
  • –mode=explain するとこのような実行計画的なのが表示されるのだが、SQL のパーサなのに実行計画とは?というかそもそもなぜ SQL を評価できるのか、不思議といえば不思議。なんらかの参照実装的なのが入っているんだろうけれど。
$ bazel-bin/zetasql/tools/execute_query/execute_query "create table hello (foo integer)"
ERROR: INVALID_ARGUMENT: Statement not supported: CreateTableStatement [at 1:1] [type.googleapis.com/zetasql.execute_query.ParserErrorContext='\n create table hello (foo integer)']
  • テーブル定義すらできないが、そもそも式を評価できる時点で不思議なので別にいいといえばいいです。はい。

次回はもうちょっとコード読みます。

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s