Esempio n. 1
0
def test_605_with_reuse_tables_true_table_changed():
    "605 gpload with reuse_tables is true, but table's schema is changed, the staging table isn't reused."
    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',
                      error_limit=1002,
                      truncate=False)
Esempio n. 2
0
def test_606_with_reuse_tables_true_port_changed():
    "606 gpload with reuse_tables is true, but port is changed, external table is not reused"
    write_config_file(mode='insert',
                      reuse_tables=True,
                      fast_match=False,
                      file='data_file.txt',
                      table='texttable',
                      input_port='8899',
                      error_limit=1002,
                      truncate=False)
Esempio n. 3
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)")
Esempio n. 4
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)
Esempio n. 5
0
def test_608_gpload_ext_staging_table():
    "608 gpload ignore staging_table if the reuse is false"
    file = mkpath('setup.sql')
    runfile(file)
    copy_data('external_file_13.csv', 'data_file.csv')
    write_config_file(reuse_tables=False,
                      format='csv',
                      file='data_file.csv',
                      table='csvtable',
                      delimiter="','",
                      log_errors=True,
                      error_limit=10,
                      staging_table='staging_table')
Esempio n. 6
0
def test_653_gpload_sql_before_creating_table():
    "653 gpload creates target table in `before sql`"
    # Actually, gpload doesn't support doing this
    # as it firstly checks if the target table exists,
    # then executes the 'before sql'

    file = mkpath('setup.sql')
    runfile(file)
    sql = '''CREATE TABLE texttable_653 (c1 int);'''
    write_config_file(format='text',
                      table='texttable_653',
                      sql=True,
                      before=sql)
Esempio n. 7
0
def test_601_with_trucate_true():
    "601 gpload with truncate is true"
    file = mkpath('setup.sql')
    runfile(file)
    f = open(mkpath('query601.sql'), 'a')
    f.write("\\! psql -d reuse_gptest -c 'select count(*) from testtruncate;'")
    f.close()
    copy_data('external_file_04.txt', 'data_file.txt')
    write_config_file(mode='insert',
                      reuse_tables=False,
                      fast_match=False,
                      file='data_file.txt',
                      table='testtruncate',
                      error_limit=1002,
                      truncate=True)
Esempio n. 8
0
def test_602_with_reuse_tables_true():
    "602 gpload with reuse_tables is true"
    drop_tables()
    file = mkpath('setup.sql')
    runfile(file)
    f = open(mkpath('query602.sql'), 'a')
    f.write(
        "\\! psql -d reuse_gptest -c \"SELECT count(*) from pg_class WHERE relname like 'ext_gpload_reusable%' OR relname like 'staging_gpload_reusable%';\""
    )
    f.close()
    copy_data('external_file_04.txt', 'data_file.txt')
    write_config_file(mode='insert',
                      reuse_tables=True,
                      fast_match=False,
                      file='data_file.txt',
                      table='texttable',
                      error_limit=1002,
                      truncate=False)
Esempio n. 9
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)")
Esempio n. 10
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)")
Esempio n. 11
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')")