예제 #1
0
def test_invalid_format():
    t = sa.Table('t1', sa.MetaData(), schema='schema1')
    with pytest.raises(ValueError):
        dialect.CopyCommand(table=t,
                            data_location='s3://bucket',
                            access_key_id=access_key_id,
                            secret_access_key=secret_access_key,
                            format=';drop table bobby_tables;')
예제 #2
0
def test_invalid_compression():
    with pytest.raises(ValueError):
        dialect.CopyCommand(
            table=tbl,
            data_location='s3://bucket/of/joy',
            access_key_id=access_key_id,
            secret_access_key=secret_access_key,
            compression=';drop table bobby_tables;',
        )
예제 #3
0
def test_format():
    expected_result = """
    COPY t1 FROM 's3://mybucket/data/listing/'
    CREDENTIALS '%s'
    JSON TRUNCATECOLUMNS DELIMITER ',' IGNOREHEADER 0 EMPTYASNULL BLANKSASNULL
    """ % creds
    copy = dialect.CopyCommand(
        table=tbl2,
        data_location='s3://mybucket/data/listing/',
        access_key_id=access_key_id,
        secret_access_key=secret_access_key,
        format='JSON',
    )
    assert clean(expected_result) == clean(compile_query(copy))
예제 #4
0
def test_compression():
    expected_result = """
    COPY schema1.t1 FROM 's3://mybucket/data/listing/'
    CREDENTIALS '%s'
    CSV TRUNCATECOLUMNS DELIMITER ',' IGNOREHEADER 0 LZOP
    EMPTYASNULL BLANKSASNULL
    """ % creds
    copy = dialect.CopyCommand(
        table=tbl,
        data_location='s3://mybucket/data/listing/',
        access_key_id=access_key_id,
        secret_access_key=secret_access_key,
        compression='LZOP',
    )
    assert clean(expected_result) == clean(compile_query(copy))