<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
    <Name>IsAnalytics-SparkScript-AuthenticationData</Name>
    <Script>
        CREATE TEMPORARY TABLE isUserAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, username FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, username, identityProviderType", incrementalParams "isUserAuthenticationAnalyticsPerMinute, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserAuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, username FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, username, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isUserAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserAuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, username FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, username, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserAuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, username FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, username, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserAuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, username FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, username, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isLocalUserAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_LocalUserAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, localUsername FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, localUsername, identityProviderType", incrementalParams "isLocalUserAuthenticationAnalyticsPerMinute, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isLocalUserAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_LocalUserAuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, localUsername FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, localUsername, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isLocalUserAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isLocalUserAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_LocalUserAuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, localUsername FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, localUsername, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isLocalUserAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_LocalUserAuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, localUsername FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, localUsername, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isLocalUserAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_LocalUserAuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, localUsername FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, localUsername, identityProviderType", mergeSchema "false");


        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i,day INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, identityProviderType FACET -i ,facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, username,role,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, username,role,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, username,role,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i, remoteIp FACET -i, region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, identityProviderType FACET -i,facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, username,role,serviceProvider,identityProvider,remoteIp,userStoreDomain, identityProviderType", incrementalParams "isRoleAuthenticationAnalyticsPerMinute, MINUTE", mergeSchema "false");

        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerMinuteDuplicate USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i, remoteIp FACET -i, region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, username,role,serviceProvider,identityProvider,remoteIp,userStoreDomain, identityProviderType", incrementalParams "isRoleAuthenticationAnalyticsPerMinuteDuplicate, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isRoleAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_RoleAuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, username FACET -i,role FACET -i,serviceProvider FACET -i,identityProvider FACET -i,remoteIp FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp,identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, username,role,serviceProvider,identityProvider,remoteIp,region,userStoreDomain, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isRoleAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isServiceProviderAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_SpAuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, serviceProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, serviceProvider, identityProviderType,facetStartTime,  _timestamp", mergeSchema "false");

        CREATE TEMPORARY TABLE isServiceProviderAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_SpAuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, serviceProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, serviceProvider, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isServiceProviderAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_SpAuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, serviceProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, serviceProvider, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isServiceProviderAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_SpAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, serviceProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, serviceProvider, identityProviderType", incrementalParams "isServiceProviderAuthenticationAnalyticsPerMinute, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isServiceProviderAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_SpAuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, serviceProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, serviceProvider, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isServiceProviderAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isIdentityProviderAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_IdpAuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, identityProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, identityProvider, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isIdentityProviderAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_IdpAuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, identityProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, identityProvider, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isIdentityProviderAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_IdpAuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, identityProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, identityProvider, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isIdentityProviderAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_IdpAuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, identityProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, identityProvider, identityProviderType", incrementalParams "isIdentityProviderAuthenticationAnalyticsPerMinute, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isIdentityProviderAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_IdpAuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, identityProvider FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, identityProvider, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isIdentityProviderAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i,day INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i,day INT -i,hour INT -i, minute INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i, remoteIp FACET -i, region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i ,facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,remoteIp,userStoreDomain, identityProviderType", incrementalParams "isAuthenticationAnalyticsPerMinute, MINUTE", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerMinuteDuplicate USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i,day INT -i,hour INT -i, minute INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i, remoteIp FACET -i, region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp,authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,remoteIp,userStoreDomain, identityProviderType", incrementalParams "isAuthenticationAnalyticsPerMinuteDuplicate, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isAuthenticationAnalyticsPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_AuthStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i,day INT -i,hour INT -i, username FACET -i, localUsername FACET -i, rolesCommaSeparated FACET -i,serviceProvider FACET -i,identityProvider FACET -i,remoteIp FACET -i,region FACET -i,userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, authFirstSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,remoteIp,region,userStoreDomain, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserstoreAuthenticationAnalyticsPerDay USING CarbonAnalytics OPTIONS (tableName "org_wso2_is_analytics_stream_UserstoreAuthStatPerDay",schema "meta_tenantId INT -i,year INT -i, month INT -i, day INT -i, userStoreDomain FACET -i, authSuccessCount LONG -sp, authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",primaryKeys "meta_tenantId, year, month, day, userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserstoreAuthenticationAnalyticsPerMonth USING CarbonAnalytics OPTIONS (tableName "org_wso2_is_analytics_stream_UserstoreAuthStatPerMonth",schema "meta_tenantId INT -i, year INT -i, month INT -i, userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",primaryKeys "meta_tenantId, year, month, userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserstoreAuthenticationAnalyticsPerYear USING CarbonAnalytics OPTIONS (tableName "org_wso2_is_analytics_stream_UserstoreAuthStatPerYear",schema "meta_tenantId INT -i, year INT -i, userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",primaryKeys "meta_tenantId, year, userStoreDomain, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserstoreAuthenticationAnalyticsPerMinute USING CarbonAnalytics OPTIONS (tableName "org_wso2_is_analytics_stream_UserstoreAuthStatPerMinute",schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -I, minute INT -i, userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",primaryKeys "meta_tenantId, year, month, day, hour, minute, userStoreDomain, identityProviderType", incrementalParams "isUserstoreAuthenticationAnalyticsPerMinute, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserstoreAuthenticationAnalyticsPerHour USING CarbonAnalytics OPTIONS (tableName "org_wso2_is_analytics_stream_UserstoreAuthStatPerHour",schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -I, userStoreDomain FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",primaryKeys "meta_tenantId, year, month, day, hour, userStoreDomain, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isUserstoreAuthenticationAnalyticsPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerMinute USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, remoteIp FACET -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, facetStartTime FACET -i, identityProviderType FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, remoteIp, identityProviderType", incrementalParams "isUserRegionStatPerMinute, MINUTE", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerMinuteDuplicate USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerMinute",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i, minute INT -i, remoteIp FACET -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, facetStartTime FACET -i, identityProviderType FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour, minute, remoteIp, identityProviderType", incrementalParams "isUserRegionStatPerMinuteDuplicate, HOUR", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerHour USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerHour",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, hour INT -i,remoteIp FACET -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, hour,remoteIp, region, identityProviderType,facetStartTime,  _timestamp", incrementalParams "isUserRegionStatPerHour, DAY", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerDay USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerDay",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, day INT -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, day, region, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerMonth USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerMonth",
        schema "meta_tenantId INT -i, year INT -i, month INT -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, month, region, identityProviderType", mergeSchema "false");

        CREATE TEMPORARY TABLE isUserRegionStatPerYear USING CarbonAnalytics
        OPTIONS (tableName "org_wso2_is_analytics_stream_UserRegionStatPerYear",
        schema "meta_tenantId INT -i, year INT -i, region FACET -i, authSuccessCount LONG -sp,authFailureCount LONG -sp, authStepSuccessCount LONG -sp, identityProviderType FACET -i, facetStartTime FACET -i, _timestamp LONG",
        primaryKeys "meta_tenantId, year, region, identityProviderType", mergeSchema "false");

        INSERT INTO TABLE isUserRegionStatPerMinuteDuplicate SELECT meta_tenantId, year, month, day, hour, minute, remoteIp, getCountry(remoteIp) as region,authSuccessCount,authFailureCount, authStepSuccessCount, facetStartTime, identityProviderType, _timestamp  FROM isUserRegionStatPerMinute;

        INCREMENTAL_TABLE_COMMIT isUserRegionStatPerMinute;

        INSERT INTO TABLE isAuthenticationAnalyticsPerMinuteDuplicate SELECT meta_tenantId, year, month, day, hour, minute, username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider, remoteIp, getCountry(remoteIp) as region,userStoreDomain,authSuccessCount,authFailureCount,authStepSuccessCount, authFirstSuccessCount, identityProviderType, facetStartTime, _timestamp FROM isAuthenticationAnalyticsPerMinute;

        INCREMENTAL_TABLE_COMMIT isAuthenticationAnalyticsPerMinute;


        INSERT INTO TABLE isRoleAuthenticationAnalyticsPerMinuteDuplicate SELECT meta_tenantId, year, month,day,hour,minute,username,role,serviceProvider,identityProvider, remoteIp, getCountry(remoteIp) as region,userStoreDomain,authSuccessCount,authFailureCount,authStepSuccessCount, identityProviderType, facetStartTime, _timestamp FROM isRoleAuthenticationAnalyticsPerMinute;

        INCREMENTAL_TABLE_COMMIT isRoleAuthenticationAnalyticsPerMinute;

        INSERT INTO TABLE isRoleAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month,day,hour,username,role,serviceProvider,identityProvider,remoteIp,getCountry(remoteIp) as region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount),identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp FROM isRoleAuthenticationAnalyticsPerMinuteDuplicate GROUP BY username, role, serviceProvider, identityProvider, remoteIp,userStoreDomain, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isRoleAuthenticationAnalyticsPerMinuteDuplicate;


        INSERT INTO TABLE isRoleAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month,day,username,role,serviceProvider,identityProvider,region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isRoleAuthenticationAnalyticsPerHour GROUP BY username, role, serviceProvider, identityProvider, region,userStoreDomain, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isRoleAuthenticationAnalyticsPerHour;


        INSERT INTO TABLE isRoleAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,username,role,serviceProvider,identityProvider,region,userStoreDomain,SUM(isRoleAuthenticationAnalyticsPerDay.authSuccessCount) as authSuccessCount,SUM(isRoleAuthenticationAnalyticsPerDay.authFailureCount) as authFailureCount,SUM(isRoleAuthenticationAnalyticsPerDay.authStepSuccessCount) as authStepSuccessCount, identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isRoleAuthenticationAnalyticsPerDay GROUP BY username, role, serviceProvider, identityProvider, region,userStoreDomain, year, month, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isRoleAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, username,role,serviceProvider,identityProvider,region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isRoleAuthenticationAnalyticsPerMonth GROUP BY username, role, serviceProvider, identityProvider, region,userStoreDomain, year, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isIdentityProviderAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, identityProvider,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isIdentityProviderAuthenticationAnalyticsPerMinute GROUP BY identityProvider, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isIdentityProviderAuthenticationAnalyticsPerMinute;

        INSERT INTO TABLE isIdentityProviderAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month, day,identityProvider,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isIdentityProviderAuthenticationAnalyticsPerHour GROUP BY identityProvider, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isIdentityProviderAuthenticationAnalyticsPerHour;


        INSERT INTO TABLE isIdentityProviderAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,identityProvider,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isIdentityProviderAuthenticationAnalyticsPerDay GROUP BY identityProvider, year, month, identityProviderType, meta_tenantId;



        INSERT INTO TABLE isIdentityProviderAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, identityProvider,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isIdentityProviderAuthenticationAnalyticsPerMonth GROUP BY identityProvider, year, identityProviderType, meta_tenantId;

        INSERT INTO TABLE isServiceProviderAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, serviceProvider,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType,cast(getHourStartingTime(year, month, day, hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day, hour) as _timestamp FROM isServiceProviderAuthenticationAnalyticsPerMinute GROUP BY serviceProvider, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isServiceProviderAuthenticationAnalyticsPerMinute;


        INSERT INTO TABLE isServiceProviderAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month, day,serviceProvider,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isServiceProviderAuthenticationAnalyticsPerHour GROUP BY serviceProvider, year, month, day, identityProviderType,cast(getDateStartingTime(year, month, day) as STRING),getDateStartingTime(year, month, day), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isServiceProviderAuthenticationAnalyticsPerHour;


        INSERT INTO TABLE isServiceProviderAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month, serviceProvider, SUM(authSuccessCount), SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isServiceProviderAuthenticationAnalyticsPerDay GROUP BY serviceProvider, year, month, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isServiceProviderAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, serviceProvider, SUM(authSuccessCount), SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isServiceProviderAuthenticationAnalyticsPerMonth GROUP BY serviceProvider, year, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isUserAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, username,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isUserAuthenticationAnalyticsPerMinute GROUP BY username, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserAuthenticationAnalyticsPerMinute;


        INSERT INTO TABLE isUserAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month, day,username,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isUserAuthenticationAnalyticsPerHour GROUP BY username, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserAuthenticationAnalyticsPerHour;

        INSERT INTO TABLE isUserAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,username,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType,cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isUserAuthenticationAnalyticsPerDay GROUP BY username, year, month, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isUserAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, username,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType , cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isUserAuthenticationAnalyticsPerMonth GROUP BY username, year, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isLocalUserAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, localUsername,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isLocalUserAuthenticationAnalyticsPerMinute GROUP BY localUsername, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isLocalUserAuthenticationAnalyticsPerMinute;


        INSERT INTO TABLE isLocalUserAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month, day,localUsername,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isLocalUserAuthenticationAnalyticsPerHour GROUP BY localUsername, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isLocalUserAuthenticationAnalyticsPerHour;

        INSERT INTO TABLE isLocalUserAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,localUsername,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType,cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isLocalUserAuthenticationAnalyticsPerDay GROUP BY localUsername, year, month, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isLocalUserAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, localUsername,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType , cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isLocalUserAuthenticationAnalyticsPerMonth GROUP BY localUsername, year, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, username, localUsername,rolesCommaSeparated,serviceProvider,identityProvider,remoteIp,getCountry(remoteIp) as region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isAuthenticationAnalyticsPerMinuteDuplicate GROUP BY username, localUsername, rolesCommaSeparated, serviceProvider, identityProvider, remoteIp,userStoreDomain, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isAuthenticationAnalyticsPerMinuteDuplicate;


        INSERT INTO TABLE isAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month,day,username,localUsername,rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isAuthenticationAnalyticsPerHour GROUP BY username, localUsername, rolesCommaSeparated, serviceProvider, identityProvider, region,userStoreDomain, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isAuthenticationAnalyticsPerHour;


        INSERT INTO TABLE isAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,username, localUsername, rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isAuthenticationAnalyticsPerDay GROUP BY username, localUsername,rolesCommaSeparated, serviceProvider, identityProvider, region,userStoreDomain, year, month, identityProviderType, meta_tenantId;



        INSERT INTO TABLE isAuthenticationAnalyticsPerYear SELECT meta_tenantId, year,username,localUsername,rolesCommaSeparated,serviceProvider,identityProvider,region,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount),SUM(authStepSuccessCount), SUM(authFirstSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isAuthenticationAnalyticsPerMonth GROUP BY username, localUsername, rolesCommaSeparated, serviceProvider, identityProvider, region,userStoreDomain, year, identityProviderType, meta_tenantId;

        INSERT INTO TABLE isUserstoreAuthenticationAnalyticsPerHour SELECT meta_tenantId, year, month, day, hour, userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isUserstoreAuthenticationAnalyticsPerMinute GROUP BY userStoreDomain, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserstoreAuthenticationAnalyticsPerMinute;

        INSERT INTO TABLE isUserstoreAuthenticationAnalyticsPerDay SELECT meta_tenantId, year, month, day,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isUserstoreAuthenticationAnalyticsPerHour GROUP BY userStoreDomain, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserstoreAuthenticationAnalyticsPerHour;

        INSERT INTO TABLE isUserstoreAuthenticationAnalyticsPerMonth SELECT meta_tenantId, year, month,userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isUserstoreAuthenticationAnalyticsPerDay GROUP BY userStoreDomain, year, month, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isUserstoreAuthenticationAnalyticsPerYear SELECT meta_tenantId, year, userStoreDomain,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isUserstoreAuthenticationAnalyticsPerMonth GROUP BY userStoreDomain, year, identityProviderType, meta_tenantId;


        INSERT INTO TABLE isUserRegionStatPerHour SELECT meta_tenantId, year, month, day, hour,remoteIp, getCountry(remoteIp) as region,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getHourStartingTime(year, month, day,hour) as STRING) as facetStartTime, getHourStartingTime(year, month, day,hour) as _timestamp  FROM isUserRegionStatPerMinuteDuplicate GROUP BY remoteIp, year, month, day, hour, identityProviderType,cast(getHourStartingTime(year, month, day,hour) as STRING),getHourStartingTime(year, month, day,hour), meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserRegionStatPerMinuteDuplicate;


        INSERT INTO TABLE isUserRegionStatPerDay SELECT meta_tenantId, year, month, day,region,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getDateStartingTime(year, month, day) as STRING) as facetStartTime, getDateStartingTime(year, month, day) as _timestamp FROM isUserRegionStatPerHour GROUP BY region, year, month, day, identityProviderType, meta_tenantId;

        INCREMENTAL_TABLE_COMMIT isUserRegionStatPerHour;

        INSERT INTO TABLE isUserRegionStatPerMonth SELECT meta_tenantId, year, month,region,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getMonthStartingTime(year, month) as STRING) as facetStartTime, getMonthStartingTime(year, month) as _timestamp FROM isUserRegionStatPerDay GROUP BY region, year, month, identityProviderType, meta_tenantId;



        INSERT INTO TABLE isUserRegionStatPerYear SELECT meta_tenantId, year, region,SUM(authSuccessCount),SUM(authFailureCount), SUM(authStepSuccessCount), identityProviderType, cast(getMonthStartingTime(year, 1) as STRING) as facetStartTime, getMonthStartingTime(year, 1) as _timestamp FROM isUserRegionStatPerMonth GROUP BY region, year, identityProviderType, meta_tenantId;



    </Script>
    <CronExpression>0 0/5 * * * ?</CronExpression>
</Analytics>
