Esempio n. 1
0
    public void CreateTable_IfNotExists()
    {
        //Arrange
        var creationMetadata = GetEntityCreationMetadata(topicName: "my_movie");

        //Act
        string statement = StatementGenerator.CreateTable <CreateEntityTests.MyMovie>(creationMetadata, ifNotExists: true);

        //Assert
        statement.Should().Be($"CREATE TABLE IF NOT EXISTS{GetExpectedClauses(isTable: true)}");
    }
Esempio n. 2
0
    /// <summary>
    /// Create a new table with the specified columns and properties.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="creationMetadata">Table properties, specify details about your table by using the WITH clause.</param>
    /// <param name="ifNotExists">If the IF NOT EXISTS clause is present, the statement won't fail if a table with the same name already exists.</param>
    /// <param name="cancellationToken">Optional cancellation token to cancel the operation</param>
    /// <returns>Http response object.</returns>
    public Task <HttpResponseMessage> CreateTableAsync <T>(EntityCreationMetadata creationMetadata, bool ifNotExists = false, CancellationToken cancellationToken = default)
    {
        if (creationMetadata == null)
        {
            throw new ArgumentNullException(nameof(creationMetadata));
        }

        var ksql = StatementGenerator.CreateTable <T>(creationMetadata, ifNotExists);

        return(ExecuteAsync <T>(ksql, cancellationToken));
    }
Esempio n. 3
0
    public void CreateSourceTable()
    {
        //Arrange
        var creationMetadata = GetEntityCreationMetadata(topicName: "my_movie");

        creationMetadata.IsReadOnly = true;

        //Act
        string statement = StatementGenerator.CreateTable <CreateEntityTests.MyMovie>(creationMetadata);

        //Assert
        statement.Should().Be($"CREATE SOURCE TABLE{GetExpectedClauses(isTable: true)}");
    }