Hi, You can achieve this by storing the macro definition in a separate HQL file and 'import' this as needed. Unfortunately such imports are interpreted by your Hive client and the relevant command varies between client implementations: '!run' in Beeline and 'SOURCE' in Hive CLI. I raised a proposal to create a unified command that is compatible across clients but this has yet to gain any traction: https://issues.apache.org/jira/browse/HIVE-12703
Elliot. On 30 September 2016 at 10:23, Staņislavs Rogozins < stanislavs.rogoz...@gmail.com> wrote: > The Unit testing wiki page > <https://cwiki.apache.org/confluence/display/Hive/Unit+Testing+Hive+SQL> > suggests > using macros to 'extract and resuse the expressions applied to columns' and > that they can be 'readily isolated for testing'. However as far as I'm > aware, right now only temporary macros can be created, that stop existing > outside of session where they were defined(https://cwiki.apache. > org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Create/ > DropMacro), thus making it necessary to include the macro in every HQL > script that uses it. How is it possible to isolate them for testing? >