3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

LookMLで型変換した場合はtypeも変換しよう

3
Last updated at Posted at 2019-10-17

LookML内のSQL記述で型変換した場合、typeも合わせて変換しないとエラーになるという話。

利用DB:bigquery(Legacy SQL)

CASE文で型変換をする

LookMLでCASE式を使って型変換を行い、LookMLを保存する。
スクリーンショット 2019-10-17 16.27.00.png

フィルタに変換後の値を指定すると、以下のようなエラーが発生する。
スクリーンショット 2019-10-17 16.40.55.png

対策方法

LookMLでCASE式を使って型変換を行う場合は、typeも同時に変更する。
スクリーンショット 2019-10-17 16.36.26.png

上記対策後は、エラーが発生しなくなる。
スクリーンショット 2019-10-17 16.48.02.png

まとめ

・LookML内にSQLを指定することで、様々な加工が行えるが、その際、必ずデータの型も意識した修正対応が必要です。
※試してはないのですが、Mysqlなどであれば型の違いをDBが吸収してくれる場合もありますので、別のDB使ってる場合は上記現象発生しないのかもしれません。(試された方がいたら共有頂けると嬉しいです。)

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?