<?xml version="1.0" encoding="UTF-8" ?>
<!--
  ~ Copyright (c) DbVis Software AB. All Rights Reserved.
  -->

<!DOCTYPE DatabaseProfile SYSTEM "dbvis-defs.dtd">

<DatabaseProfile desc="Profile for Snowflake" minver="9.5" extends="generic">

   <!-- =================================================================== -->
   <!-- Definition of initialization commands -->
   <!-- =================================================================== -->

   <InitCommands extends="true">

      <Command id="snowflake.ROLE_IS_SECURITY_ADMIN">
         <SQL>
            <![CDATA[
SELECT 1 from INFORMATION_SCHEMA.ENABLED_ROLES 
WHERE ROLE_NAME = 'ACCOUNTADMIN' OR ROLE_NAME = 'SECURITYADMIN';
            ]]>
         </SQL>
         <Output index="1" name="ROLE_IS_SECURITY_ADMIN"/>
         <OnError>
            <If test="#result.getErrorCode() eq 608" context="runtime">
               <Message type="info">
                  <![CDATA[
                    Could not check if SECURITYADMIN or ACCOUNTADMIN is active as Warehouse is not started. Please resume a Warehouse and login again. 
                ]]>
               </Message>
            </If>
            <Else>
              <Message type="info">
                  <![CDATA[
                    Got error when checking if SECURITYADMIN or ACCOUNTADMIN is active. Admin functionality may be affected.
                ]]>
              </Message>
            </Else>
         </OnError>
      </Command>

   </InitCommands>

   <!-- =================================================================== -->
   <!-- Definition of the commands -->
   <!-- =================================================================== -->

   <Commands extends="true">

      <Command id="snowflake.getSchemas">
         <SQL>
            <![CDATA[
            SELECT * FROM "${catalog}".INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME]]>
         </SQL>

      </Command>

      <Command id="snowflake.getSchemaNames">

         <SQL>
            <![CDATA[
                SELECT SCHEMA_NAME FROM "${catalog}".INFORMATION_SCHEMA.SCHEMATA ORDER BY SCHEMA_NAME;
            ]]>
         </SQL>

         <!--Must have Filter element here since this command is fetched from code -->
         <Filter index="SCHEMA_NAME" label="Name"/>
      </Command>

      <!-- The "getTableNamesFor" command is used by Database getTableNamesFor(). It must return table names for the catalog and schema named by the ${table_catalog} 
         and ${table_catalog} variables in the first column. -->

      <Command id="snowflake.getTableNamesFor">
         <SQL>
            <![CDATA[
            SELECT TABLE_NAME FROM "${table_catalog}".INFORMATION_SCHEMA.TABLES WHERE TABLES.TABLE_SCHEMA = '${table_schema}' AND TABLES.TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getTables">
         <SQL>
            <![CDATA[
            SELECT * FROM "${catalog}".INFORMATION_SCHEMA.TABLES WHERE TABLES.TABLE_SCHEMA = '${schema}' AND TABLES.TABLE_TYPE = ${type} ORDER BY TABLE_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getExternalTables">
         <SQL>
            <![CDATA[
            show external tables in ${catalog}.${schema};
            ]]>
         </SQL>
      </Command>

	  <Command id="snowflake.getExternalTable">
         <SQL>
            <![CDATA[
            DESCRIBE EXTERNAL TABLE "${catalog}"."${schema}"."${objectname}";
            ]]>
         </SQL>
      </Command>


	  <Command id="snowflake.getMaterializedViews">
         <SQL>
            <![CDATA[
            show materialized views in ${catalog}.${schema};
            ]]>
         </SQL>
      </Command>

	  <Command id="snowflake.getMaterializedView">
         <SQL>
            <![CDATA[
            DESCRIBE materialized view "${catalog}"."${schema}"."${objectname}";
            ]]>
         </SQL>
      </Command>

      <!-- The "getColumnNamesFor" command is used by Database getColumnNamesFor(). It must return column names for the catalog, schema and table named
         by the ${table_catalog}, ${table_catalog} and ${table_name} variables in the first column. -->
      <Command id="snowflake.getColumnNamesFor">
         <SQL>
            <![CDATA[
            SELECT COLUMN_NAME FROM "${table_catalog}".INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '${table_schema}' AND TABLE_NAME = '${table_name}' order by COLUMN_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getSequences">
         <SQL>
            <![CDATA[
            SELECT * FROM "${catalog}".INFORMATION_SCHEMA.SEQUENCES WHERE SEQUENCE_SCHEMA = '${schema}' ORDER BY SEQUENCE_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getProcedures">
         <SQL>
            <![CDATA[
            SELECT * , REGEXP_REPLACE(ARGUMENT_SIGNATURE, '\\(?([,]\\s*)?\\w*\\s*(\\w*)\\)?', '\\1\\2') AS ARG_TYPES 
            FROM "${catalog}".INFORMATION_SCHEMA.PROCEDURES WHERE PROCEDURE_SCHEMA = '${schema}' ORDER BY PROCEDURE_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getFunctions">
         <SQL>
            <![CDATA[
            SELECT * , REGEXP_REPLACE(ARGUMENT_SIGNATURE, '\\(?([,]\\s*)?\\w*\\s*(\\w*)\\)?', '\\1\\2') AS ARG_TYPES 
            FROM "${catalog}".INFORMATION_SCHEMA.FUNCTIONS WHERE FUNCTION_SCHEMA = '${schema}' ORDER BY FUNCTION_NAME;
            ]]>
         </SQL>
      </Command>

       <Command id="snowflake.getFileFormats">
         <SQL>
            <![CDATA[
            SHOW FILE FORMATS IN SCHEMA "${catalog}"."${schema}";
            ]]>
         </SQL>
      </Command>

       <Command id="snowflake.getFileFormat">
         <SQL>
            <![CDATA[
            DESCRIBE FILE FORMAT "${catalog}"."${schema}"."${objectname}";
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getStages">
         <SQL>
            <![CDATA[
            SHOW STAGES IN SCHEMA "${catalog}"."${schema}";
            ]]>
         </SQL>
      </Command>

       <Command id="snowflake.getStage">
         <SQL>
            <![CDATA[
            DESCRIBE STAGE "${catalog}"."${schema}"."${objectname}";
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getPipes">
         <SQL>
            <![CDATA[
            SHOW PIPES IN SCHEMA "${catalog}"."${schema}";
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getPipe">
         <SQL>
            <![CDATA[
            DESCRIBE PIPE "${catalog}"."${schema}"."${objectname}";
            ]]>
         </SQL>
      </Command>

      <!-- ================================================================= -->
      <!-- DBA related commands requiring certain privileges in the database -->
      <!-- ================================================================= -->

      <!-- The command can only be executed by users with a role that has the
           MANAGE GRANTS global privilege. This privilege is usually only granted to
           the ACCOUNTADMIN and SECURITYADMIN roles
      -->
      <Command id="snowflake.getUsers">
         <SQL>
            <![CDATA[
show users
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="name"/>
      </Command>
      
      <Command id="snowflake.getRoles">
         <SQL>
            <![CDATA[
SHOW ROLES
            ]]>
         </SQL>
         <ProcessDataSet action="movecolumn" index="name" value="first"/>
         <ProcessDataSet action="sortcolumn" index="name"/>
      </Command>

      <Command id="snowflake.getEnabledRoles">
         <SQL>
            <![CDATA[
select * from INFORMATION_SCHEMA.ENABLED_ROLES ORDER BY ROLE_NAME;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getRoleGrants">
         <SQL>
            <![CDATA[SHOW GRANTS OF ROLE ${name}
           ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getLocks">
         <SQL>
            <![CDATA[
SHOW LOCKS
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="resource"/>
      </Command>

      <Command id="snowflake.getParameters">
         <SQL>
            <![CDATA[
SHOW PARAMETERS IN ACCOUNT
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="snowflake.getWarehouses">
         <SQL>
            <![CDATA[
SHOW WAREHOUSES
           ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="name"/>
      </Command>
      
      <Command id="snowflake.getWarehousesMeteringHistory">
         <SQL>
            <![CDATA[
select * from table(information_schema.warehouse_metering_history(dateadd('days',-10,current_date())))
           ]]>
         </SQL>
      </Command>
      
      <Command id="snowflake.describeUser">
         <SQL>
            <![CDATA[
DESCRIBE USER ${user}
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getLoginAttempts">
         <SQL>
            <![CDATA[
select *  from table(information_schema.login_history_by_user('${user}', result_limit=>1000))
order by event_timestamp desc;
            ]]>
         </SQL>
      </Command>

      <Command id="snowflake.getQueryHistory">
         <SQL>
            <![CDATA[
select * from table(information_schema.query_history(RESULT_LIMIT => 1000))
order by start_time desc;
            ]]>
         </SQL>
         <ProcessDataSet action="movecolumn" index="QUERY_TEXT" value="first"/>
         <ProcessDataSet action="movecolumn" index="EXECUTION_STATUS" value="first"/>
         <ProcessDataSet action="movecolumn" index="END_TIME" value="first"/>
         <ProcessDataSet action="movecolumn" index="START_TIME" value="first"/>
      </Command>

           <Command id="snowflake.getQueryHistoryByUser">
         <SQL>
            <![CDATA[
select * from table(information_schema.query_history_by_user(USER_NAME => '${user}', RESULT_LIMIT => 1000))
order by start_time desc;
            ]]>
         </SQL>
         <ProcessDataSet action="movecolumn" index="QUERY_TEXT" value="first"/>
         <ProcessDataSet action="movecolumn" index="EXECUTION_STATUS" value="first"/>
         <ProcessDataSet action="movecolumn" index="END_TIME" value="first"/>
         <ProcessDataSet action="movecolumn" index="START_TIME" value="first"/>
      </Command>

      <Command id="snowflake.getOldQueryResult">
         <SQL>
            <![CDATA[
select * from table(result_scan('${queryId}'));
            ]]>
         </SQL>
      </Command>
   </Commands>

   <!-- =================================================================== -->
   <!-- Definition of the object actions that are used by the tree and views -->
   <!-- =================================================================== -->

   <ObjectsActionDef extends="false">
      <ActionGroup type="Catalogs">
         <Action id="snowflake-databases-create" label="Create Database" reload="true" resetcatalogs="true" icon="add">
            <Input label="Database" name="newDatabase" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[
                  create database ${QB}${newDatabase}${QE}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm creation of ${newDatabase}?
            </Confirm>
            <Result>
               Database ${newDatabase} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Catalog">
         <Action id="snowflake-catalog-rename" label="Rename Database" reload="true" resetcatalogs="true" icon="rename">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="New Database Name" name="newDatabase" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[ALTER DATABASE "${catalog}" RENAME TO ${QB}${newDatabase}${QE}]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm rename of ${catalog} to ${newDatabase}?
            </Confirm>
            <Result>
               Database ${catalog} renamed to ${newDatabase}!
            </Result>
         </Action>

         <!-- TODO CLONE -->

         <Action id="snowflake-catalog-drop" label="Drop Database" reload="true" resetcatalogs="true" icon="remove">
            <!-- DROP DATABASE [ IF EXISTS ] <name> [ CASCADE | RESTRICT ] -->
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check"
               tip="Enable this if you want to drop the database and all objects in the database in on single operation">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop database "${catalog}" ${cascade}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm drop of ${catalog}?
            </Confirm>
            <Result>
               Database ${catalog} dropped!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Schemas">
         <Action id="snowflake-schemas-create" label="Create Schema" reload="true" resetschemas="true" icon="add">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="New Schema" name="newSchema" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[
                  create schema "${catalog}".${QB}${newSchema}${QE}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm creation of ${newSchema}?
            </Confirm>
            <Result>
               Schema ${newSchema} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Schema">
         <Action id="snowflake-schema-drop" label="Drop Schema" reload="true" resetschemas="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check"
               tip="Enable this if you want to drop the schema and all objects in the database in on single operation">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop schema "${catalog}"."${schema}"  ${cascade}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm drop of ${schema}?
            </Confirm>
            <Result>
               Schema ${schema} dropped!
            </Result>
         </Action>

         <Action id="snowflake-schema-export" label="Export Schema" icon="export" reload="false" class="schemaExport"
            doclink="/doclink/export-schema"/>
      </ActionGroup>

      <ActionGroup type="Tables">
         <Action id="snowflake-tables-create-table" label="Create Table" icon="add" reload="true" class="tableCreateOrAlter" classargs="create"
            doclink="/doclink/create-table"/>
         <Action id="snowflake-tables-import-table-data" label="Import Table Data" icon="import" reload="true" class="tableDataImport"
            doclink="/doclink/import-table"/>
      </ActionGroup>

      <ActionGroup type="Table">
         <Action id="snowflake-tables-alter-table" label="Alter Table" icon="edit" reload="true" class="tableCreateOrAlter" classargs="alter"
            doclink="/doclink/alter-table"/>

         <Action id="snowflake-table-rename" label="Rename Table" reload="true" icon="rename">
            <!-- ALTER TABLE TEST_DB.public.TAB_RENAME_ME RENAME TO TEST_DB.public.TAB_MYNEWNAME; -->
            <Message>
               <![CDATA[<html>
                 Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Table Name" name="newTable" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[ALTER TABLE "${catalog}"."${schema}"."${objectname}", "${catalog}"."${schema}".${QB}${newTable}${QE}]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newTable}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="snowflake-table-clear" label="Empty Table" reload="true">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Use Command" name="useCommand" style="radio">
               <Values>TRUNCATE|DELETE</Values>
               <Default>TRUNCATE</Default>
            </Input>

            <SetVar name="_command" value="#useCommand.equals('TRUNCATE') ? 'truncate table' : 'delete from'"/>

            <Command>
               <SQL>
                  <![CDATA[
                  ${_command} "${catalog}"."${schema}"."${objectname}"
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really remove all rows in table ${schema}.${objectname}?
            </Confirm>
            <Result>
               All rows in table ${schema}.${objectname} has been removed!
            </Result>
         </Action>

         <!-- DROP TABLE [ IF EXISTS ] <name> [ CASCADE | RESTRICT ] -->
         <Action id="snowflake-table-drop" label="Drop Table" reload="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check"
               tip="Enable this if you want to drop the table even if the table has primary/unique keys that are referenced by foreign keys in other tables">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop table "${catalog}"."${schema}"."${objectname}" ${cascade}
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="snowflake-table-import-table-data" label="Import Table Data" icon="import" class="tableDataImport"
            doclink="/doclink/import-table"/>

         <Action id="snowflake-table-export" label="Export Table" icon="export" class="tableExport"
            doclink="/doclink/export-table"/>

         <Separator/>

         <Action id="snowflake-table-script" label="Script Table" icon="scriptObject" class="sqlBuilder"
            classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="View">
         <Action id="snowflake-view-drop" label="Drop View" reload="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop view "${catalog}"."${schema}"."${objectname}"
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop view ${schema}.${objectname}?
            </Confirm>
            <Result>
               View ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <!-- ALTER VIEW [ IF EXISTS ] <name> RENAME TO <new_name> -->
         <Action id="snowflake-view-rename" label="Rename View" reload="true" icon="rename">
            <Message>
               <![CDATA[<html>
                 Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New View Name" name="newView" style="text"/>
            <Command>
               <SQL><![CDATA[ALTER VIEW "${catalog}"."${schema}"."${objectname}" RENAME TO "${catalog}"."${schema}".${QB}${newView}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newView}?
            </Confirm>
            <Result>
               View ${schema}.${objectname} renamed to ${newView}!
            </Result>
         </Action>

         <Action id="snowflake-view-export" label="Export View" icon="export" class="viewExport"
            doclink="/doclink/export-view"/>
         <Separator/>

         <Action id="snowflake-view-script" label="Script View" icon="scriptObject" class="sqlBuilder"
            classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Column">
         <!-- snowflake-column-rename: Not supported in snowflake -->

         <!-- TODO: Edit comment -->
         <!-- alter table t1 alter c5 comment '50 character column'; -->

         <!-- End Extended props for columns -->
      </ActionGroup>

      <ActionGroup type="Procedures">
         <Action id="snowflake-procedures-create" label="Create Procedure" reload="true" icon="add"
            doclink="/doclink/create-procedure">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure Name" name="procedureName" style="text"/>

            <Input label="Execute as" name="executeas" style="list">
               <Values>OWNER|CALLER</Values>
               <Default>OWNER</Default>
            </Input>

            <Input label="Immutable" name="immutable" style="check"
               tip="If enabled the procedure assumes that, when called with the same inputs, it will always return the same result.">
               <Values>Immutable</Values>
            </Input>

            <Input label="Parameters" style="separator"/>

            <Input name="parameters" style="grid">
               <Arg name="output" value="${name} ${type}"/>
               <Arg name="newline" value=", "/>

               <Input name="name" label="Name" style="text">
                  <Default>parm</Default>
               </Input>
               <Input name="type" label="Type" style="text">
                  <Default>VARCHAR(20)</Default>
               </Input>
            </Input>

            <Input name="returntype" label="Returns Type" style="text">
               <Default>VARCHAR(20)</Default>
            </Input>

            <SetVar name="_parameters" value='#parameters.trim().equals("") ? "" : "(" + #parameters + ")"'/>
            <SetVar name="_return" value='#returntype.trim().equals("") ? "" : "return \u005c\u0022something\u005c\u0022;"'/>
            <Command exectype="asis">
               <SQL>
                  <![CDATA[
CREATE PROCEDURE "${catalog}"."${schema}".${QB}${procedureName}${QE}
${_parameters}
RETURNS ${returntype}
LANGUAGE javascript
${immutable}
EXECUTE AS ${executeas}
AS
$$
   /* Procedure body */
   ${_return}
$$;
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Create procedure ${procedureName}?
            </Confirm>
            <Result>
               Procedure ${procedureName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Procedure">
         <Action id="snowflake-procedure-drop" label="Drop Procedure" reload="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop procedure "${catalog}"."${schema}"."${objectname}" (${snowflake.getProcedures.ARG_TYPES})
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop procedure ${schema}.${objectname}?
            </Confirm>
            <Result>
               Procedure ${schema}.${getDDLObjectId} dropped!
            </Result>
         </Action>

         <Action id="snowflake-procedure-rename" label="Rename Procedure" reload="true" icon="rename">
            <Message>
               <![CDATA[<html>
                 Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Procedure Name" name="newProcedure" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[ALTER PROCEDURE "${catalog}"."${schema}"."${objectname}" (${snowflake.getProcedures.ARG_TYPES}) RENAME TO  "${catalog}"."${schema}".${QB}${newProcedure}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of procedure ${schema}.${objectname} to
               ${newProcedure}?
            </Confirm>
            <Result>
               Procedure ${objectname} renamed to ${newProcedure}!
            </Result>
         </Action>

         <Action id="snowflake-procedure-Comment" label="Comment Procedure" reload="true">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Procedure" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${snowflake.getProcedures.COMMENT}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[ALTER PROCEDURE "${catalog}"."${schema}"."${objectname}" (${snowflake.getProcedures.ARG_TYPES}) SET COMMENT = '${comment}' ]]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${getDDLObjectId}?
            </Confirm>
         </Action>

         <Action id="snowflake-procedure-export" label="Export Procedure" icon="export" class="procedureExport"
            doclink="/doclink/export-code-object"/>

         <Separator/>

         <Action id="snowflake-procedure-script" label="Script Procedure" icon="scriptObject" class="sqlBuilder"
            classargs="script-dialog,CALL,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Functions">
         <Action id="snowflake-functions-create" label="Create Function" reload="true" icon="add"
            doclink="/doclink/create-function">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function Name" name="functionName" style="text"/>
            <Input label="Return Data Type" name="returns" style="text">
               <Default>VARCHAR(20)</Default>
            </Input>

            <Input label="Immutable" name="immutable" style="check"
               tip="If enabled the function assumes that, when called with the same inputs, it will always return the same result.">
               <Values>Immutable</Values>
            </Input>

            <Input label="Is Javascript" name="javascript" style="check"
               tip="If enabled the function_definition must contain JavaScript code; otherwise, function_definition must contain a SQL expression.">
               <Values>LANGUAGE JAVASCRIPT</Values>
            </Input>
            <Input label="Parameters" style="separator"/>

            <Input name="parameters" style="grid">
               <Arg name="output" value="${name} ${type}"/>
               <Arg name="newline" value=", "/>

               <Input name="name" label="Name" style="text">
                  <Default>@parm</Default>
               </Input>
               <Input name="type" label="Type" style="text">
                  <Default>VARCHAR(20)</Default>
               </Input>
            </Input>

            <SetVar name="_parameters" value='#parameters.trim().equals("()") ? "" : "(" + #parameters + ")"'/>
            <Command exectype="asis">
               <SQL>
                  <![CDATA[
CREATE FUNCTION "${catalog}"."${schema}".${QB}${functionName}${QE}
${_parameters}
RETURNS ${returns}
${javascript}
${immutable}
AS
/* function body */
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Create function "${schema}".${functionName}?
            </Confirm>
            <Result>
               Function ${schema}.${functionName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Function">
         <Action id="snowflake-function-drop" label="Drop Function" reload="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop function "${catalog}"."${schema}"."${objectname}" (${snowflake.getFunctions.ARG_TYPES})
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop function ${schema}.${getDDLObjectId}?
            </Confirm>
            <Result>
               Function ${schema}.${getDDLObjectId} dropped!
            </Result>
         </Action>

         <Action id="snowflake-function-rename" label="Rename Function" reload="true" icon="rename">
            <Message>
               <![CDATA[<html>
                 Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Function Name" name="newFunction" style="text"/>
            <Command>
               <SQL>
                   <![CDATA[ALTER FUNCTION "${catalog}"."${schema}"."${objectname}"  (${snowflake.getFunctions.ARG_TYPES}) RENAME TO  "${catalog}"."${schema}".${QB}${newProcedure}${QE}]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm rename of function ${schema}.${getDDLObjectId} to
               ${newFunction}?
            </Confirm>
            <Result>
               Function ${objectname} renamed to ${newFunction}!
            </Result>
         </Action>

         <Action id="snowflake-function-Comment" label="Comment Function" reload="true">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${snowflake.getFunctions.COMMENT}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[ALTER FUNCTION "${catalog}"."${schema}"."${objectname}" (${snowflake.getFunctions.ARG_TYPES}) SET COMMENT = '${comment}' ]]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${getDDLObjectId}?
            </Confirm>
         </Action>

         <Action id="snowflake-function-export" label="Export Function" icon="export" class="functionExport"
            doclink="/doclink/export-code-object"/>

         <Separator/>

         <Action id="snowflake-function-script" label="Script Function" icon="scriptObject" class="sqlBuilder"
            classargs="script-dialog,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="MaterializedView">
         <Action id="snowflake-materializedview-drop" label="Drop Materialized View" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop materialized view "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really drop materialized view ${schema}.${objectname}?
            </Confirm>
            <Result>
               Materialized view ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="snowflake-materializedview-script" label="Script Materialized View" icon="scriptObject"
            class="sqlBuilder"
            classargs="script-dialog,SELECT,SELECT *"/>
      </ActionGroup>

      <ActionGroup type="Sequences">
         <Action id="snowflake-sequences-create" label="Create Sequence" reload="true" icon="add">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence Name" name="sequenceName" style="text"/>

            <Input label="Start With" name="startWith" style="text">
               <Default>1</Default>
            </Input>

            <Input label="Increment By" name="increment" style="text">
               <Default>1</Default>
            </Input>

            <Command>
               <SQL>
                  <![CDATA[create sequence "${schema}".${QB}${sequenceName}${QE} ${sequenceName} start with ${startWith} increment by ${increment}]]>
               </SQL>
            </Command>
            <Result>
               Sequence ${schema}.${sequenceName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Sequence">
         <Action id="snowflake-sequence-drop" label="Drop Sequence" reload="true" icon="remove">
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  drop sequence "${schema}"."${objectname}"
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop sequence ${schema}.${objectname}?
            </Confirm>
            <Result>
               Sequence ${schema}.${objectname} dropped!
            </Result>
         </Action>
         <Action id="snowflake-sequence-rename" label="Rename Sequence" reload="true" icon="rename">
            <Message type="warning">
               <![CDATA[<html>
                 Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Sequence Name" name="newSequence" style="text"/>
            <Command>
               <SQL>
                   <![CDATA[ALTER SEQUENCE "${catalog}"."${schema}"."${objectname} RENAME TO  "${catalog}"."${schema}".${QB}${newSequence}${QE}]]>
               </SQL>
            </Command>
            <Confirm>
               Confirm rename of function ${schema}.${objectname} to
               ${newSequence}?
            </Confirm>
            <Result>
               Function ${objectname} renamed to ${newSequence}!
            </Result>
         </Action>
      </ActionGroup>

      <!-- DBA Actions -->

      <!-- Role Actions -->
      <ActionGroup type="Roles">
         <If test="#ROLE_IS_SECURITY_ADMIN eq 1">
            <Action id="snowflake-roles-create" label="Create Role" reload="true" icon="add">
               <Input label="Name" name="name" style="text"/>
               <Input label="Comment" name="comment" style="text-editor"/>
               <Command>
                  <SQL>
                  <![CDATA[
                  CREATE Role ${name} Comment = '${comment}';
                  ]]>
                  </SQL>
               </Command>

               <Result>
                  Role created!
               </Result>
            </Action>
         </If>
         <Else>
            <Action id="snowflake-roles-create-INFO" label="Create Role" icon="add">
               <Confirm>
                  <![CDATA[
                      Insufficient privileges to run this action.
                  ]]>
               </Confirm>
            </Action>
         </Else>
      </ActionGroup>

      <ActionGroup type="Role">
         <If test="#ROLE_IS_SECURITY_ADMIN eq 1">
            <Action id="snowflake-role-drop" label="Drop Role" reload="true" icon="remove">
               <Input label="Role" style="text" editable="false">
                  <Default>${objectname}</Default>
               </Input>
               <Command>
                  <SQL>
                  <![CDATA[
                  Drop Role ${objectname};
                  ]]>
                  </SQL>
               </Command>

               <Result>
                  Role ${objectname} has been dropped!
               </Result>
            </Action>
         </If>
         <Else>
            <Action id="snowflake-role-drop-INFO" label="Drop Role" icon="remove">
               <Confirm>
                  <![CDATA[
                      Insufficient privileges to run this action.
                  ]]>
               </Confirm>
            </Action>
         </Else>
      </ActionGroup>

      <!-- User Actions -->
      <ActionGroup type="Users">
         <If test="#ROLE_IS_SECURITY_ADMIN eq 1">
            <Action id="snowflake-users-create" label="Create User" reload="true" icon="add">
               <Input name="name" label="Name" style="text"/>
               <Input name="password" label="Password" style="password"/>
               <Input name="loginName" label="Login Name" style="text"/>
               <Input name="displayName" label="Display Name" style="text"/>
               <Input name="firstName" label="First Name" style="text"/>
               <Input name="middleName" label="Middle Name" style="text"/>
               <Input name="lastName" label="Last Name" style="text"/>
               <Input name="email" label="Email" style="text"/>
               <Input name="mustChangePassword" label="Must Change Password" style="radio">
                  <Values>TRUE|FALSE</Values>
                  <Labels>TRUE|FALSE</Labels>
                  <Default>FALSE</Default>
               </Input>
               <Input name="disabled" label="Disabled" style="radio">
                  <Values>TRUE|FALSE</Values>
                  <Labels>TRUE|FALSE</Labels>
                  <Default>FALSE</Default>
               </Input>
               <Input name="snowflakeSupport" label="Snowflake Support" style="radio">
                  <Values>TRUE|FALSE</Values>
                  <Labels>TRUE|FALSE</Labels>
                  <Default>FALSE</Default>
               </Input>
               <Input name="defaultWarehouse" label="Default Warehouse" style="list">
                  <Values>
                     <Command idref="snowflake.getWarehouses">
                        <ProcessDataSet action="addrow" index="first" value="-- Do not set --"/>
                     </Command>
                  </Values>
               </Input>
               <Input name="defaultRole" label="Default Role" style="list">
                  <Values>
                     <Command idref="snowflake.getRoles">
                        <ProcessDataSet action="addrow" index="first" value="-- Do not set --"/>
                     </Command>
                  </Values>
               </Input>
               <Input name="daysToExpire" label="Days To Expire" style="number"/>
               <Input name="minsToUnlock" label="Minutes To Unlock" style="number"/>
               <Input name="defaultNamespace" label="Default Namespace" style="text"
                  tip="Specifies the namespace (database only or database and schema) that is active by default for the user’s session upon login"/>
               <Input name="minsToBypassMFA" label="Minutes To Bypass MFA" style="number"
                  tip="Specifies the number of minutes to temporarily bypass MFA for the user"/>
               <Input name="rsaPublicKey" label="RSA Public Key" style="text"
                  tip="Specifies the user’s RSA public key; used for key pair authentication."/>
               <Input name="rsaPublicKey2" label="RSA Public Key 2" style="text"
                  tip="Specifies the user’s second RSA public key; used to rotate the public and private keys for key pair authentication based on an expiration schedule set by your organization"/>

               <SetVar name="_loginName" value='#loginName.equals("") ? "" : "LOGIN_NAME = \u0027" + #loginName + "\u0027"'/>
               <SetVar name="_displayName" value='#displayName.equals("") ? "" : "DISPLAY_NAME = \u0027" + #displayName + "\u0027"'/>
               <SetVar name="_middleName" value='#middleName.equals("") ? "" : "MIDDLE_NAME = \u0027" + #middleName + "\u0027"'/>
               <SetVar name="_lastName" value='#lastName.equals("") ? "" : "LAST_NAME = \u0027" + #lastName + "\u0027"'/>

               <SetVar name="_disabled" value='#disabled.equals("TRUE") ? "DISABLED = TRUE " : ""'/>
               <SetVar name="_mustChangePw" value='#mustChangePassword.equals("TRUE") ? "MUST_CHANGE_PASSWORD = TRUE " : ""'/>

               <SetVar name="_snowflakeSupport" value='#snowflakeSupport.equals("TRUE") ? "SNOWFLAKE_SUPPORT = TRUE " : ""'/>

               <SetVar name="_daysToExpire" value='#daysToExpire.equals("") ? "" : "DAYS_TO_EXPIRY = " + #daysToExpire'/>
               <SetVar name="_minsToUnlock" value='#minsToUnlock.equals("") ? "" : "MINS_TO_UNLOCK " + #minsToUnlock'/>
               <SetVar name="_email" value='#email.equals("") ? "" : "EMAIL = \u0027" + #email + "\u0027"'/>

               <SetVar name="_minsToUnlock" value='#minsToUnlock.equals("") ? "" : "MINS_TO_UNLOCK = " + #minsToUnlock'/>
               <SetVar name="_defaultWarehouse" value='#defaultWarehouse.equals("-- Do not set --") ? "" : " DEFAULT_WAREHOUSE = " + #defaultWarehouse'/>
               <SetVar name="_defaultRole" value='#defaultRole.equals("-- Do not set --") ? "" : "DEFAULT_ROLE = " + #defaultRole'/>
               <SetVar name="_defaultNamespace" value='#defaultNamespace.equals("") ? "" : "DEFAULT_NAMESPACE = " + #defaultNamespace'/>
               <SetVar name="_minsToBypassMFA" value='#minsToBypassMFA.equals("") ? "" : "MINS_TO_BYPASS_MFA = " + #minsToBypassMFA'/>
               <SetVar name="_rsaPublicKey" value='#rsaPublicKey.equals("") ? "" : "RSA_PUBLIC_KEY = " + #rsaPublicKey'/>
               <SetVar name="_rsaPublicKey2" value='#rsaPublicKey2.equals("") ? "" : "RSA_PUBLIC_KEY_2 = " + #rsaPublicKey2'/>

               <Command>
                  <SQL>
                  <![CDATA[
 CREATE USER ${name} PASSWORD = '${password}' ${_loginName} ${_displayName} ${_middleName} ${_lastName} ${_email}
  ${_mustChangePw}
  ${_disabled}
  ${_snowflakeSupport}
  ${_daysToExpire}
  ${_minsToUnlock}
  ${_defaultWarehouse}
  ${_defaultRole}
  ${_defaultNamespace}
  ${_minsToBypassMFA}
  ${_rsaPublicKey}
  ${_rsaPublicKey2}
                  ]]>
                  </SQL>
               </Command>

               <Result>
                  User ${name} created !
               </Result>
            </Action>
         </If>
         <Else>
            <Action id="snowflake-users-create-INFO" label="Create User" icon="add">
               <Confirm>
                  <![CDATA[
                      Insufficient privileges to run this action.
                  ]]>
               </Confirm>
            </Action>
         </Else>
      </ActionGroup>

      <ActionGroup type="User">
         <Action id="snowflake-user-drop" label="Drop User" reload="true" icon="remove">
            <Input label="User" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  Drop User ${objectname};
                  ]]>
               </SQL>
            </Command>

            <Result>
               User ${objectname} has been dropped!
            </Result>
         </Action>
         <Action id="snowflake-user-rename" label="Rename User" reload="true" icon="rename">
            <Input label="Old User Name" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New User Name" name="newname" style="text" editable="true">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  ALTER USER ${objectname} RENAME TO ${newname};
                  ]]>
               </SQL>
            </Command>
            <Result>
               User ${objectname} has been renamed!
            </Result>
         </Action>
         <Action id="snowflake-user-abort-all-queries" label="Abort all queries" reload="true" icon="remove">
            <Message type="warning">
               <![CDATA[<html>
                 Aborts all the queries and other SQL statements currently running or scheduled by the user, regardless of the warehouse on which the queries are running/scheduled
               ]]>
            </Message>
            <Input label="Abort queries for user" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  ALTER USER ${objectname} ABORT ALL QUERIES;
                  ]]>
               </SQL>
            </Command>

            <Result>
               Queries for User ${objectname} has been aborted!
            </Result>
         </Action>

         <Action id="snowflake-user-disable-enable" label="Disable/Enable User" reload="true" icon="edit">
            <Message type="warning">
               <![CDATA[<html>
                 Disabling a user means that all running/scheduled queries for the user are Aborted.
                 Also prevent the user from logging into Snowflake or initiating new queries.
               ]]>
            </Message>
            <Input label="User" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input name="currentDisableStatus" label="Current disable Status" style="text" editable="false">
               <Default>
                  <Command>
                     <SQL>
                        <![CDATA[SHOW USERS LIKE '${objectname}' ]]>
                     </SQL>
                     <ProcessDataSet action="movecolumn" index="disabled" value="first"/>
                  </Command>
               </Default>
            </Input>
            <Input label="New disable status" style="text" editable="false">
               <Default>${_newEnableStatus}</Default>
            </Input>
            <SetVar name="_newEnableStatus" value='#currentDisableStatus.equals("true") ? "false" : "true"'/>

            <Command>
               <SQL>
                  <![CDATA[
                   ALTER USER ${objectname} SET DISABLED = ${_newEnableStatus};
                  ]]>
               </SQL>
            </Command>

            <Result>
               User ${objectname} has been disabled!
            </Result>
         </Action>
      </ActionGroup>
    
      <ActionGroup type="Warehouses">
         <Action id="snowflake-warehouses-create" label="Create Warehouse" reload="true" icon="add">
            <Input label="Name" name="name" style="text"/>
            <Input name="size" label="Size"  style="list">
               <Values>XSMALL|SMALL|MEDIUM|LARGE|XLARGE|XXLARGE|XXXLARGE|X4LARGE</Values>
               <Default>XSMALL</Default>
            </Input>
            <Input name="maxClusterCount" label="Max Cluster Count" style="number">
               <Default>1</Default>
             </Input>
             <Input name="minClusterCount" label="Min Cluster Count" style="number">
                <Default>1</Default>
             </Input>
             <Input name="scalingPolicy" label="Scaling Policy"  style="list">
                <Values>STANDARD|ECONOMY</Values>
                <Default>STANDARD</Default>
             </Input>
             <Input name="autoSuspend" label="Auto Suspend" style="number">
                <Default>600</Default>
             </Input>
             <Input name="autoResume" label="Auto Resume"  style="check">
                <Values>true|false</Values>
                <Default>true</Default>
             </Input>
             <Input name="initiallySuspended" label="Initially Suspended"  style="check">
                <Values>true|false</Values>
                <Default>true</Default>
             </Input>
            <SetVar name="_autoSuspend" value='#autoSuspend.equals("0") ? "NULL" : #autoSuspend'/>

            <SetVar name="_scalingPolicyDDL" value='#scalingPolicy.equals("STANDARD") ? "" : "SCALING_POLICY=" + #scalingPolicy'/>

            <Command>
               <SQL>
                  <![CDATA[
                    create warehouse ${name} warehouse_size=${size} MAX_CLUSTER_COUNT=${maxClusterCount} MIN_CLUSTER_COUNT=${minClusterCount} ${_scalingPolicyDDL}
                    AUTO_SUSPEND=${_autoSuspend} AUTO_RESUME=${autoResume} INITIALLY_SUSPENDED=${initiallySuspended};
                  ]]>
               </SQL>
            </Command>

            <Result>
               Warehouse created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Warehouse">
         <Action id="snowflake-warehouse-resume-suspend" label="Resume/Suspend" reload="true" icon="edit">
            <Input label="Current Warehouse Status" name="currentStatus" style="text" editable="false">
               <Default>
                  <Command>
                     <SQL>
                        <![CDATA[SHOW WAREHOUSES LIKE '${objectname}' ]]>
                     </SQL>
                     <ProcessDataSet action="movecolumn" index="state" value="first"/>
                  </Command>
               </Default>
            </Input>
            <Input label="New Warehouse Status" name="newStatus" style="text" editable="false">
               <Default> ${_dowhat}</Default>
            </Input>

            <SetVar name="_dowhat" value="#currentStatus.equals('STARTED') ? 'SUSPEND' : 'RESUME'"/>

            <Command>
               <SQL>
                  <![CDATA[
                  alter warehouse ${objectname} ${_dowhat};
                  ]]>
               </SQL>
            </Command>

            <Result>
               Warehouse status changed!
            </Result>
         </Action>

         <Action id="snowflake-warehouse-drop" label="Drop Warehouse" reload="true" icon="remove">
            <Input label="Warehouse" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[
                  Drop Warehouse ${objectname};
                  ]]>
               </SQL>
            </Command>

            <Result>
               Warehouse ${objectname} has been dropped!
            </Result>
         </Action>
      </ActionGroup>

   </ObjectsActionDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects tree structure -->
   <!-- =================================================================== -->

   <ObjectsTreeDef extends="false">
      <GroupNode type="Catalogs" label="Databases">
         <DataNode type="Catalog" label="${getCatalogs.TABLE_CAT}">
            <SetVar name="catalog" value="${getCatalogs.TABLE_CAT}"/>
            <Command idref="getCatalogs">
               <Filter index="DATABASE_NAME" label="Name"/>
            </Command>

            <GroupNode type="Schemas" label="Schemas">
               <DataNode type="Schema" label="${snowflake.getSchemas.SCHEMA_NAME}">
                  <SetVar name="schema" value="${snowflake.getSchemas.SCHEMA_NAME}"/>
                  <Command idref="snowflake.getSchemas">
                     <Input name="catalog" value="${catalog}"/>
                     <Filter index="SCHEMA_NAME" label="Name"/>
                  </Command>

                  <GroupNode type="Tables" label="Tables">
                     <DataNode type="Table" label="${snowflake.getTables.TABLE_NAME}">
                        <SetVar name="objectname" value="${snowflake.getTables.TABLE_NAME}"/>
                        <SetVar name="rowcount" value="true"/>
                        <SetVar name="acceptInQB" value="true"/>
                        <Command idref="snowflake.getTables">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                           <Input name="type" value="'BASE TABLE'"/>
                        </Command>

                        <!-- Need to keep the objectname for the current table in a new variable so that the viewers will be able to pick up the correct
                           input to display -->

                        <SetVar name="theTableName" value="${objectname}"/>

                        <!-- The object type below is used to being able to distinguish Views from tables when editing managing extended properties for
                           view columns. -->
                        <GroupNode type="Columns" label="Columns">
                           <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}" label1="${getColumnDefinitions.TYPE_NAME}"
                              isLeaf="true" icon="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'PrimaryKey' : 'Column'"
                              tip="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'This is a primary key column' : ''">
                              <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                              <Command idref="getColumnDefinitions">
                                 <Input name="catalog" value="${catalog}"/>
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="objectname" value="${theTableName}"/>
                                 <Input name="tableType" value="Table"/>
                                 <Filter index="TYPE_NAME" label="Type"/>
                              </Command>
                           </DataNode>
                        </GroupNode>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Views" label="Views">
                     <DataNode type="View" label="${snowflake.getTables.TABLE_NAME}">
                        <SetVar name="schema" value="${snowflake.getTables.TABLE_SCHEMA}"/>
                        <SetVar name="objectname" value="${snowflake.getTables.TABLE_NAME}"/>
                        <SetVar name="rowcount" value="true"/>
                        <SetVar name="acceptInQB" value="true"/>
                        <Command idref="snowflake.getTables">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                           <Input name="type" value="'VIEW'"/>
                        </Command>

                        <!-- Need to keep the objectname for the current table in a new variable so that the viewers will be able to pick up the correct
                           input to display -->
                        <SetVar name="theTableName" value="${objectname}"/>

                        <GroupNode type="Columns" label="Columns">
                           <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}" label1="${getColumnDefinitions.TYPE_NAME}"
                              isLeaf="true">
                              <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                              <Command idref="getColumnDefinitions">
                                 <Input name="catalog" value="${catalog}"/>
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="objectname" value="${theTableName}"/>
                                 <Input name="tableType" value="View"/>
                                 <Filter index="TYPE_NAME" label="Type"/>
                              </Command>
                           </DataNode>
                        </GroupNode>
                     </DataNode>
                  </GroupNode>

                  <SetVar name="theTableName" value="%"/>

                  <GroupNode type="Sequences" label="Sequences">
                     <DataNode type="Sequence" label="${snowflake.getSequences.SEQUENCE_NAME}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getSequences.SEQUENCE_NAME}"/>
                        <Command idref="snowflake.getSequences">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                           <Input name="table" value="%"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <SetVar name="theTableName" value="%"/>

                  <GroupNode type="Procedures" label="Stored Procedures">
                     <DataNode type="Procedure" label="${snowflake.getProcedures.PROCEDURE_NAME} (${snowflake.getProcedures.ARG_TYPES})"
                        isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getProcedures.PROCEDURE_NAME}"/>
                        <SetVar name="getDDLObjectId" value="${snowflake.getProcedures.PROCEDURE_NAME} (${snowflake.getProcedures.ARG_TYPES})"/>
                        <SetVar name="getDDLName" value="${snowflake.getProcedures.PROCEDURE_NAME} (${snowflake.getProcedures.ARG_TYPES})"/>
                        <Command idref="snowflake.getProcedures">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Functions" label="Functions">
                     <DataNode type="Function" label="${snowflake.getFunctions.FUNCTION_NAME} (${snowflake.getFunctions.ARG_TYPES})"
                        isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getFunctions.FUNCTION_NAME}"/>
                        <SetVar name="getDDLName" value="${snowflake.getFunctions.FUNCTION_NAME} (${snowflake.getFunctions.ARG_TYPES})"/>
                        <SetVar name="getDDLObjectId" value="${snowflake.getFunctions.FUNCTION_NAME} (${snowflake.getFunctions.ARG_TYPES})"/>
                        <Command idref="snowflake.getFunctions">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
                  <GroupNode type="ExternalTables" label="External Tables">
                     <DataNode type="ExternalTable" label="${snowflake.getExternalTables.name}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getExternalTables.name}"/>
                        <Command idref="snowflake.getExternalTables">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
                  <GroupNode type="MaterializedViews" label="Materialized Views">
                     <DataNode type="MaterializedView" label="${snowflake.getMaterializedViews.name}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getMaterializedViews.name}"/>
                        <Command idref="snowflake.getMaterializedViews">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
                  <GroupNode type="FileFormats" label="File Formats">
                     <DataNode type="FileFormat" label="${snowflake.getFileFormats.name}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getFileFormats.name}"/>
                        <Command idref="snowflake.getFileFormats">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
                  <GroupNode type="Stages" label="Stages" icon="Stage">
                     <DataNode type="Stage" label="${snowflake.getStages.name}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getStages.name}"/>
                        <Command idref="snowflake.getStages">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
                  <GroupNode type="Pipes" label="Pipes" icon="Pipe">
                     <DataNode type="Pipe" label="${snowflake.getPipes.name}" isLeaf="true">
                        <SetVar name="objectname" value="${snowflake.getPipes.name}"/>
                        <Command idref="snowflake.getPipes">
                           <Input name="catalog" value="${catalog}"/>
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
               </DataNode>
            </GroupNode>
         </DataNode>
      </GroupNode>

      <!-- ================================================================= -->
      <!-- DBA Nodes -->
      <!-- ================================================================= -->

      <GroupNode type="DBA" label="DBA Views">
         <GroupNode type="ServerInfo" label="Server Info" isLeaf="true"/>
         <GroupNode type="Users" label="Users">
            <If test="#ROLE_IS_SECURITY_ADMIN eq 1">
               <DataNode type="User" label="${snowflake.getUsers.NAME}" isLeaf="true"
                  warnstate="#dataMap.get('snowflake.getUsers.disabled').equals('true')">
                  <SetVar name="objectname" value="${snowflake.getUsers.NAME}"/>
                  <SetVar name="enabledState" value="${snowflake.getUsers.disabled}"/>
                  <Command idref="snowflake.getUsers"/>
               </DataNode>
            </If>
         </GroupNode>

         <GroupNode type="Roles" label="Roles">
            <DataNode type="Role" label="${snowflake.getRoles.name}" isLeaf="true">
               <SetVar name="objectname" value="${snowflake.getRoles.name}"/>
               <Command idref="snowflake.getRoles"/>
            </DataNode>
         </GroupNode>

         <GroupNode type="Warehouses" label="Warehouses">
            <DataNode type="Warehouse" label="${snowflake.getWarehouses.name}" label1="${snowflake.getWarehouses.STATE}"
               icon="#dataMap.get('snowflake.getWarehouses.STATE').equals('STARTED') ? 'WarehouseStarted' : 'Warehouse'" isLeaf="true">
               <SetVar name="objectname" value="${snowflake.getWarehouses.name}"/>
               <Command idref="snowflake.getWarehouses"/>
            </DataNode>
         </GroupNode>

         <GroupNode type="Locks" label="Locks" isLeaf="true"/>

         <GroupNode type="QueryHistory" label="Query History" icon="history" isLeaf="true"/>

      </GroupNode>


   </ObjectsTreeDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects views -->
   <!-- =================================================================== -->

   <ObjectsViewDef extends="true">

      <ObjectView type="Catalog" drop-on-condition="always"/>

      <ObjectView type="Schemas">
         <DataView id="generic-schemas-schemas" drop-on-condition="always"/>

         <DataView id="snowflake-schemas-schemas" icon="Schemas" label="Schemas" viewer="grid">
            <Command idref="snowflake.getSchemas">
               <Input name="catalog" value="${catalog}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Schema" drop-on-condition="always"/>

      <ObjectView type="Tables">
         <DataView id="generic-tables-tables" drop-on-condition="always"/>
         <DataView id="generic-tables-references" drop-on-condition="always"/>

         <DataView id="snowflake-tables-tables" icon="Tables" label="Tables" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop table ${schema||owner}${object||name}"/>
            </Input>
            <Command idref="snowflake.getTables">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="type" value="'BASE TABLE'"/>
            </Command>
         </DataView>
         <DataView id="snowflake-tables-references" icon="References" label="References" viewer="tables-refs"
            doclink="/doclink/show-references">
            <Command idref="getTables">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="%"/>
               <Input name="tableType" value="TABLE"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Table">
         <DataView id="generic-table-ddl" drop-on-condition="always"/>
         <DataView id="generic-table-rowid" drop-on-condition="always"/>
         <DataView id="generic-table-indexes" drop-on-condition="always"/>

         <DataView id="snowflake-table-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="formatSQL" value="true"/>
         </DataView>

      </ObjectView>

      <ObjectView type="Views">
         <DataView id="snowflake-views-views" icon="Views" label="Views" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||owner}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop table ${schema||owner}${object||name}"/>
            </Input>
            <Command idref="snowflake.getTables">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="type" value="'VIEW'"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="View">
         <DataView id="snowflake-view-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="snowflake-view-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="getColumns">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="snowflake-view-data" icon="Data" label="Data" viewer="table-data"/>
         <DataView id="snowflake-view-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>

         <DataView id="snowflake-view-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="View"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequences">
         <DataView id="snowflake-sequences-sequences" icon="Sequences" label="Sequences" viewer="grid">
            <Command idref="snowflake.getSequences">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
            <Input name="menuItem" value="Script: DROP SEQUENCE">
               <Input name="command" value="drop sequence ${schema||SEQUENCE_SCHEMA}${object||SEQUENCE_NAME}"/>
            </Input>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequence">
         <DataView id="snowflake-sequence-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Users">
         <If test="#ROLE_IS_SECURITY_ADMIN eq 1">
            <DataView id="snowflake-users-users" icon="Users" label="Users" viewer="grid">
               <Command idref="snowflake.getUsers">
                  <Input name="catalog" value="${catalog}"/>
               </Command>
            </DataView>
         </If>
         <Else>
            <DataView id="snowflake-users-users" icon="Users" label="Users" viewer="message">
               <Message>
             <![CDATA[
<html>
Insufficient privileges. The 'securityadmin' role is required to view users.
</html>
         ]]>
               </Message>
            </DataView>
         </Else>
      </ObjectView>

      <ObjectView type="User">
         <DataView id="snowflake-user-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="snowflake-user-describe" icon="Info" label="Describe" viewer="grid">
            <Command idref="snowflake.describeUser">
               <Input name="user" value="${objectname}"/>
            </Command>
         </DataView>

         <DataView id="snowflake-user-queries" icon="history" label="Last Queries" viewer="grid">
            <Message type="info">Last queries run by user. Max 1000 shown</Message>
            <Command idref="snowflake.getQueryHistoryByUser">
               <Input name="user" value="${objectname}"/>
            </Command>

            <DataView id="snowflake-user-queries-result" icon="Data" label="Result" viewer="grid">
               <Command idref="snowflake.getOldQueryResult">
                  <Input name="queryId" value="${QUERY_ID}"/>
               </Command>
            </DataView>
            <DataView id="snowflake-user-queries-info" icon="Info" label="Info" viewer="node-form"/>
         </DataView>

         <DataView id="snowflake-user-login-attempts" icon="history" label="Login Attempts" viewer="grid">
            <Message>
             <![CDATA[
<html>
Shows up to the last 1000 login events of the user.
</html>
         ]]>
            </Message>
            <Command idref="snowflake.getLoginAttempts">
               <Input name="user" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Roles">
         <DataView id="snowflake-roles-roles" icon="Roles" label="Roles" viewer="grid">
            <Command idref="snowflake.getRoles">
               <Input name="catalog" value="${catalog}"/>
            </Command>
         </DataView>
         <DataView id="snowflake-roles-enabled-roles" icon="Roles" label="Enabled Roles" viewer="grid">
            <Message>
             <![CDATA[
<html>
Displays a row for each currently enabled role in the session. A role is enabled if it is currently in use in the
session or it has been granted to the role that is currently in use.
</html>
         ]]>
            </Message>
            <Command idref="snowflake.getEnabledRoles"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Role">
         <DataView id="snowflake-role-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="snowflake-role-users" icon="Users" label="Role grants" viewer="grid">
            <Command idref="snowflake.getRoleGrants">
               <Input name="catalog" value="${catalog}"/>
               <Input name="name" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Warehouses">
         <DataView id="snowflake-warehouses-warehouses" icon="Warehouses" label="Warehouses" viewer="grid">
            <Command idref="snowflake.getWarehouses"/>
         </DataView>
         <DataView id="snowflake-warehouses-metering-history" icon="history" label="Metering history 10 days" viewer="grid">
            <Message>
             <![CDATA[
<html>
Shows hourly warehouse usage over the past 10 days for all warehouses that ran during this time period. <br>
<b>Note</b>: Returns results only for the 'accountadmin' role or any role that has been explicitly granted the MONITOR USAGE global privilege.
</html>
         ]]>
            </Message>
            <Command idref="snowflake.getWarehousesMeteringHistory"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Warehouse">
         <DataView id="snowflake-warehouse-info" icon="Warehouse" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Procedures">
         <DataView id="generic-procedures-procedures" drop-on-condition="always"/>

         <DataView id="snowflake-procedures-procedures" icon="Procedures" label="Procedures" viewer="grid">
            <Command idref="snowflake.getProcedures">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Procedure">
         <DataView id="generic-procedure-columns" drop-on-condition="always"/>

         <DataView classargs="PROCEDURE" id="snowflake-procedure-procedureeditor" icon="SourceEditor" label="Procedure Editor"
            viewer="procedure-editor" doclink="/doclink/edit-code-object"/>
         <DataView id="snowflake-procedure-interface" icon="Interface" label="Interface" viewer="form">
            <Command idref="getProcedureColumns">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Functions">
         <DataView id="snowflake-functions-functions" icon="Functions" label="Functions" viewer="grid">
            <Command idref="snowflake.getFunctions">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Function">
         <DataView classargs="FUNCTION" id="snowflake-function-functioneditor" icon="SourceEditor" label="Function Editor"
            viewer="procedure-editor" doclink="/doclink/edit-code-object"/>
         <DataView id="snowflake-function-interface" icon="Interface" label="Interface" viewer="form">
            <Command idref="getProcedureColumns">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="ExternalTables">
         <DataView id="snowflake-external-tables" icon="ExternalTables" label="External Tables" viewer="grid">
            <Command idref="snowflake.getExternalTables">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

	  <ObjectView type="ExternalTable">
         <DataView id="snowflake-external-table" icon="ExternalTables" label="External Tables" viewer="grid">
            <Command idref="snowflake.getExternalTable">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
			   <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

	  <ObjectView type="MaterializedViews">
         <DataView id="snowflake-materialized-views" icon="MaterializedViews" label="Materialized Views" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||schema_name}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||schema_name}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||schema_name}${object||name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP MATERIALIZED VIEW">
               <Input name="command" value="drop materialized view ${schema||schema_name}${object||name}"/>
            </Input>

            <Command idref="snowflake.getMaterializedViews">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

	  <ObjectView type="MaterializedView">
         <DataView id="snowflake-materializedview-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="snowflake-materializedview-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="getColumns">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="snowflake-materializedview-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data">
            <Input name="editDisabled" value="true"/>
         </DataView>
         <DataView id="snowflake-materializedview-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
      </ObjectView>

      <ObjectView type="FileFormats">
         <DataView id="snowflake-fileformats-fileformats" icon="FileFormats" label="FileFormats" viewer="grid">
            <Command idref="snowflake.getFileFormats">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="FileFormat">
         <DataView id="snowflake-fileformat-fileformat" icon="FileFormat" label="FileFormat" viewer="grid">
            <Command idref="snowflake.getFileFormat">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="Stages">
         <DataView id="snowflake-stages-stages" icon="Stage" label="Stages" viewer="grid">
            <Command idref="snowflake.getStages">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="Stage">
         <DataView id="snowflake-stages-stage" icon="Stage" label="Stage" viewer="grid">
            <Command idref="snowflake.getStage">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="Pipes">
         <DataView id="snowflake-pipes-pipes" icon="Pipe" label="Pipes" viewer="grid">
            <Command idref="snowflake.getPipes">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>
      
      <ObjectView type="Pipe">
         <DataView id="snowflake-pipes-pipe" icon="Pipe" label="Pipe" viewer="grid">
            <Command idref="snowflake.getPipe">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <!-- ================================================================= -->
      <!-- DBA Views -->
      <!-- ================================================================= -->

      <ObjectView type="ServerInfo">
         <DataView id="snowflake-serverinfo-parameters" icon="ServerInfo" label="Parameters" viewer="grid">
            <Command idref="snowflake.getParameters"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Locks">
         <DataView id="snowflake-locks-locks" icon="Locks" label="Locks" viewer="grid">
            <Command idref="snowflake.getLocks"/>
         </DataView>
      </ObjectView>

      <ObjectView type="QueryHistory">
         <DataView id="snowflake-queryhistory-queries" icon="history" label="Last Queries" viewer="grid">
            <Message type="info">Last queries run. Max 1000 shown</Message>
            <Command idref="snowflake.getQueryHistory"/>
              
            <DataView id="snowflake-queryhistory-queries-result" icon="Data" label="Result" viewer="grid">
               <Command idref="snowflake.getOldQueryResult">
                  <Input name="queryId" value="${QUERY_ID}"/>
               </Command>
            </DataView>
            <DataView id="snowflake-queryhistory-queries-info" icon="Info" label="Info" viewer="node-form"/>
         </DataView>
     </ObjectView>

   </ObjectsViewDef>

</DatabaseProfile>
