This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("Load")] | |
public static async Task<HttpResponseMessage> Run( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "v1/load")] | |
HttpRequestMessage req, | |
ILogger logger, | |
ExecutionContext context) | |
{ | |
ServiceProvider serviceProvider = Initializer.Initialize(context); | |
string body = await req.Content.ReadAsStringAsync().ConfigureAwait(false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoadCommand | |
{ | |
public string Database { get; set; } | |
public string Schema { get; set; } | |
public string Warehouse { get; set; } | |
public string Stage { get; set; } | |
public string TargetTable { get; set; } | |
public string[] Files { get; set; } | |
public bool Force { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UnloadCommand | |
{ | |
public string Database { get; set; } | |
public string Schema { get; set; } | |
public string Warehouse { get; set; } | |
public string Stage { get; set; } | |
public string Query { get; set; } | |
public string FilePrefix { get; set; } | |
public bool SingleFile { get; set; } | |
public bool Overwrite { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SnowflakeClientExtensions | |
{ | |
/// <summary> | |
/// Instructs Snowflake to load data from a stage into a target table. | |
/// </summary> | |
public static int Load(this SnowflakeClient client, string stage, string targetTable, string[] files = null, string warehouse = null, string database = null, string schema = null, bool force = false) | |
{ | |
IList<string> commands = DefineSnowflakeQueryContext(warehouse, database, schema); | |
commands.Add(LoadSnowflakeCommand(stage, targetTable, files, force)); | |
return client.ExecuteNonQuery(commands.ToArray()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE DATABASE SALES; | |
USE SCHEMA SALES; | |
SELECT * FROM LINEITEMS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// A client for submitting queries to Snowflake. | |
/// </summary> | |
public class SnowflakeClient | |
{ | |
private readonly string connectionString; | |
/// <summary> | |
/// Initializes a new instance of the <see cref="SnowflakeClient"/> class. | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class SnowflakeClientExtensions | |
{ | |
/// <summary> | |
/// Instructs Snowflake to load data from a stage into a target table. | |
/// </summary> | |
public static int Load(this SnowflakeClient client, string stage, string targetTable, string[] files = null, string warehouse = null, string database = null, string schema = null, bool force = false) | |
{ | |
IList<string> commands = DefineSnowflakeQueryContext(warehouse, database, schema); | |
commands.Add(LoadSnowflakeCommand(stage, targetTable, files, force)); | |
return client.ExecuteNonQuery(commands.ToArray()); |
NewerOlder