private static async preIngestionQuerying()

in packages/quick_start/src/SampleApp.ts [142:176]


    private static async preIngestionQuerying(config: ConfigJson, kustoClient: KustoClient, ingestServiceCmdClient: KustoClient) {
        if (config.useExistingTable) {
            if (config.alterTable) {
                // Tip: Usually table was originally created with a schema appropriate for the data being ingested, so this wouldn't be needed.
                // Learn More: For more information about altering table schemas, see:
                // https://docs.microsoft.com/azure/data-explorer/kusto/management/alter-table-command
                await this.waitForUserToProceed(`Alter-merge existing table '${config.databaseName}.${config.tableName}' to align with the provided schema`);
                await this.alterMergeExistingTableToProvidedSchema(kustoClient, config.databaseName, config.tableName, config.tableSchema);
            }
            if (config.queryData) {
                // Learn More: For more information about Kusto Query Language (KQL), see: https://docs.microsoft.com/azure/data-explorer/write-queries
                await this.waitForUserToProceed(`Get existing row count in '${config.databaseName}.${config.tableName}'`);
                await this.queryExistingNumberOfRows(kustoClient, config.databaseName, config.tableName);
            }
        } else {
            // Tip: This is generally a one-time configuration
            // Learn More: For more information about creating tables, see: https://docs.microsoft.com/azure/data-explorer/one-click-table
            await this.waitForUserToProceed(`Creating table '${config.databaseName}.${config.tableName}'`);
            await this.createNewTable(kustoClient, config.databaseName, config.tableName, config.tableSchema);
        }

        // Learn More: Kusto batches data for ingestion efficiency. The default batching policy ingests data when one of the following conditions are met:
        //   1) More than 1,000 files were queued for ingestion for the same table by the same user
        //   2) More than 1GB of data was queued for ingestion for the same table by the same user
        //   3) More than 5 minutes have passed since the first file was queued for ingestion for the same table by the same user
        //  For more information about customizing the ingestion batching policy, see:
        // https://docs.microsoft.com/azure/data-explorer/kusto/management/batchingpolicy
        // TODO: Change if needed. Disabled on existing tables to prevent an existing batching policy from being unintentionally changed
        if (!config.useExistingTable && config.batchingPolicy != null) {
            await this.waitForUserToProceed(`Alter the batching policy for table '${config.databaseName}.${config.tableName}'`);
            await this.alterBatchingPolicy(kustoClient, config.databaseName, config.tableName, config.batchingPolicy, ingestServiceCmdClient);
        } else {
            Console.log(`\nStep 'Alter the batching policy' was skipped to avoid changing existing policy - change code if needed.`);
        }
    }