SQL editor variables

5 views
Skip to first unread message

Jean-François Desjeans Gauthier

unread,
Apr 5, 2018, 7:03:00 PM4/5/18
to Hue-Users, sme-eng-hue

Initially published on http://gethue.com/sql-editor-variables/

Greetings SQL aficionados!

We’ve been looking for ways to do small steady improvements to the usability of our editors.

Sharing

In Hue 4.1, we added the ability to share any query you’ve saved with other Hue users so that you can collaborate and share your hard work. To share, access the editor right hand menu.

Once there, you have autocomplete for the users in Hue and you can decide if they should have write access.

Variables

For some time, you’ve been able to define variables in SQL queries so that you could easily configure parameters in queries. Variables are also a great way to allow other users to customize shared queries with the values they need.

1
select * from web_logs where country_code = "${country_code}"

In Hue 4.1, we’ve added the ability to add default values to your variables. Default values can be of two types:

Single Valued

1
select * from web_logs where country_code = "${country_code=US}"

Multi Valued

1
select * from web_logs where country_code = "${country_code=CA, FR, US}"

In addition, the displayed text for multi valued variables can be changed.

1
select * from web_logs where country_code = "${country_code=CA(Canada), FR(France), US(United States)}"

In Hue 4.3, we’re adding the ability to display the column assist when clicking on the variable name, which should be handy when figuring out which value to use.

If you’re like us, remembering the correct format for dates and timestamps is the last thing you have on your mind. When the data type for the column is available in the metastore for the aforementioned types, Hue will default the value to today’s date and you’ll be able to pick the date from a calendar.

Help

Finally, if you forget how to use these new features, fret not. We’ve added a new help button  in the editor that recaps this information and more.

As always, if you have any questions, feel free to comment here or on the hue-user list or @gethue!


Hue Team

Reply all
Reply to author
Forward
0 new messages