SQL editor variables

05 April 2018 in Querying / Version 4 - 2 minutes read

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

{.p1}

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

{.p1}

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!


comments powered by Disqus

More recent stories

13 November 2019
Visually surfacing SQL information like Primary Keys, Foreign Keys, Views and Complex Types
Read More
31 October 2019
Missing some color? How to improve or add your own SQL syntax Highlighter
Read More
24 October 2019
How to create a HBase table on Kerberized Hadoop clusters
Read More