SQL editor variables

SQL editor variables

Update June 5th 2018: boolean variables were introduced in 4.3

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.

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

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

Multi Valued

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

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

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.

In Hue 4.3, we made a small improvement by displaying checkbox when using boolean values as the data type.

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!

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.