コード例 #1
0
def test_604_with_reuse_tables_true_table_changed():
    "604 gpload with reuse_tables is true and specifying a staging_table, but table's schema is changed. so staging table dosen't match the destination table, load failed"
    psql_run(cmd="ALTER TABLE texttable ADD column n8 text",
             dbname='reuse_gptest')
    copy_data('external_file_08.txt', 'data_file.txt')
    write_config_file(mode='insert',
                      reuse_tables=True,
                      fast_match=False,
                      file='data_file.txt',
                      table='texttable',
                      staging_table='staging_test',
                      error_limit=1002,
                      truncate=False)
コード例 #2
0
def test_652_gpload_sql_before_fail():
    "652 gpload fails to execute `before sql`"
    file = mkpath('setup.sql')
    runfile(file)
    sql = '''CREATE TABLE texttable_652 (c1 int);'''
    (ok, out) = psql_run(cmd=sql, dbname='reuse_gptest')
    if not ok:
        raise Exception("Unable to execute sql %s" % out)
    write_config_file(format='text',
                      table='texttable_652',
                      sql=True,
                      before="INSERT INTO test_652 VALUES(1)")
コード例 #3
0
def test_662_gpload_sql_after_fail():
    "662 gpload fails to execute `after sql`"
    file = mkpath('setup.sql')
    runfile(file)
    f = open(mkpath('query661.sql'), 'a')
    f.write("\\! psql -d reuse_gptest -c 'SELECT * FROM test_662'")
    f.write("\\! psql -d reuse_gptest -c 'SELECT COUNT(*) texttable_662'\n")
    f.close()
    sql = '''CREATE TABLE texttable_662 (
             s1 text, s2 text, s3 text, dt timestamp, n1 smallint, n2 integer, n3 bigint, n4 decimal,
             n5 numeric, n6 real, n7 double precision) DISTRIBUTED BY (n1);'''
    (ok, out) = psql_run(cmd=sql, dbname='reuse_gptest')
    if not ok:
        raise Exception("Unable to execute sql %s" % out)
    write_config_file(format='text',
                      table='texttable_662',
                      sql=True,
                      after="INSERT INTO test_662 VALUES(1)")
コード例 #4
0
def test_651_gpload_sql_before_success():
    "651 gpload executes `before sql` successfully"
    file = mkpath('setup.sql')
    runfile(file)
    f = open(mkpath('query651.sql'), 'a')
    f.write("\\! psql -d reuse_gptest -c 'SELECT COUNT(*) FROM test_651'")
    f.close()
    sql = '''CREATE TABLE texttable_651 (
             s1 text, s2 text, s3 text, dt timestamp, n1 smallint, n2 integer, n3 bigint, n4 decimal,
             n5 numeric, n6 real, n7 double precision) DISTRIBUTED BY (n1);
             CREATE TABLE test_651 (c1 int);'''
    (ok, out) = psql_run(cmd=sql, dbname='reuse_gptest')
    if not ok:
        raise Exception("Unable to execute sql %s" % out)
    write_config_file(format='text',
                      table='texttable_651',
                      sql=True,
                      before="INSERT INTO test_651 VALUES(1)")
コード例 #5
0
def test_665_gpload_sql_before_after():
    "665 gpload's before and after not in a transaction, after sql fails"
    file = mkpath('setup.sql')
    runfile(file)
    f = open(mkpath('query665.sql'), 'a')
    f.write("\\! psql -d reuse_gptest -c 'SELECT * FROM test_665_before'\n")
    f.write("\\! psql -d reuse_gptest -c 'SELECT * FROM test_665_after'\n")
    f.write(
        "\\! psql -d reuse_gptest -c 'SELECT COUNT(*) FROM texttable_665'\n")
    f.close()
    sql = '''CREATE TABLE texttable_665 (
             s1 text, s2 text, s3 text, dt timestamp, n1 smallint, n2 integer, n3 bigint, n4 decimal,
             n5 numeric, n6 real, n7 double precision) DISTRIBUTED BY (n1);
             CREATE TABLE test_665_before (c1 int);
             CREATE TABLE test_665_after (c1 int);'''
    (ok, out) = psql_run(cmd=sql, dbname='reuse_gptest')
    if not ok:
        raise Exception("Unable to execute sql %s" % out)
    write_config_file(format='text',
                      table='texttable_665',
                      sql=True,
                      before="INSERT INTO test_665_before VALUES(1)",
                      after="INSERT INTO test_665_after VALUES('a')")