looker-open-source / pylookml

A pythonic api for automatic lookml
https://pylookml.readthedocs.io/en/latest/introduction.html
MIT License
44 stars 22 forks source link

changing field delimiter to blank doesn't remove backticks #1

Closed bryan-at-looker closed 4 years ago

bryan-at-looker commented 5 years ago
import lookml

lookml.DB_FIELD_DELIMITER_START = ''

lookml.DB_FIELD_DELIMITER_END = ''

order_items = lookml.View('order_items')
order_items.setSqlTableName(sql_table_name='events',schema='public')
order_items + 'id' + 'sale_price'
order_items.addSum(order_items.sale_price)
print(order_items)

does this >>

view: order_items {
  sql_table_name: `public`.`events` ;;

  dimension: id {
    type: string
    sql: ${TABLE}.`id` ;;
  }

  dimension: sale_price {
    type: string
    sql: ${TABLE}.`sale_price` ;;
  }

  measure: total_sale_price {
    type: sum
    sql: ${sale_price} ;;
  }
}

sql property still has backticks 💥

russlooker commented 5 years ago

The packaging added an extra namespace in order to target the constant. For now change your code to:

lookml.lookml.DB_FIELD_DELIMITER_START = ''
lookml.lookml.DB_FIELD_DELIMITER_END = ''

the extra package reference is required. This will resolve the issue while I fix the namespacing.