提交 089c7c0a 编写于 作者: A Abhijit Subramanya

Cleanup some leftover changes in gpMgmt from error tables removal.

上级 ef145fe3
......@@ -1447,6 +1447,8 @@ class gpload:
# like libpq, just inherit USER
self.options.d = self.options.U
if self.getconfig('gpload:input:error_table', unicode, None):
self.control_file_error("ERROR_TABLE is not supported. Please use LOG_ERRORS instead.")
def gpfdist_port_options(self, name, availablePorts, popenList):
"""
......@@ -1965,7 +1967,7 @@ class gpload:
# This function will return the SQL to run in order to find out whether
# such a table exists.
#
def get_reuse_exttable_query(self, formatType, formatOpts, limitStr, errorTableOid, from_cols, schemaName, log_errors):
def get_reuse_exttable_query(self, formatType, formatOpts, limitStr, from_cols, schemaName, log_errors):
sqlFormat = """select attrelid::regclass
from (
select
......@@ -2008,9 +2010,7 @@ class gpload:
sql = sqlFormat % (joinStr, conditionStr)
if errorTableOid:
sql += " WHERE pgext.fmterrtbl = %d\n " % errorTableOid
elif log_errors:
if log_errors:
sql += " WHERE pgext.fmterrtbl = pgext.reloid "
else:
sql += " WHERE pgext.fmterrtbl IS NULL "
......@@ -2174,9 +2174,6 @@ class gpload:
encodingStr = self.getconfig('gpload:input:encoding', unicode, None)
limitStr = self.getconfig('gpload:input:error_limit',int, None)
if self.error_table and not limitStr:
self.control_file_error("gpload:input:error_table requires " +
"gpload:input:error_limit to be specified")
if self.log_errors and not limitStr:
self.control_file_error("gpload:input:log_errors requires " +
"gpload:input:error_limit to be specified")
......@@ -2198,17 +2195,15 @@ class gpload:
# the one that we need to use. It must have identical attributes,
# external location, format, and encoding specifications.
if self.reuse_tables == True:
if (not self.error_table or self.error_table_oid):
sql = self.get_reuse_exttable_query(formatType, formatOpts,
limitStr, self.error_table_oid, from_cols, self.extSchemaName, self.log_errors)
resultList = self.db.query(sql.encode('utf-8')).getresult()
if len(resultList) > 0:
# found an external table to reuse. no need to create one. we're done here.
self.extTableName = (resultList[0])[0]
self.extSchemaTable = self.extTableName
self.log(self.INFO, "reusing external table %s" % self.extSchemaTable)
return
sql = self.get_reuse_exttable_query(formatType, formatOpts,
limitStr, from_cols, self.extSchemaName, self.log_errors)
resultList = self.db.query(sql.encode('utf-8')).getresult()
if len(resultList) > 0:
# found an external table to reuse. no need to create one. we're done here.
self.extTableName = (resultList[0])[0]
self.extSchemaTable = self.extTableName
self.log(self.INFO, "reusing external table %s" % self.extSchemaTable)
return
# didn't find an existing external table suitable for reuse. Format a reusable
# name and issue a CREATE EXTERNAL TABLE on it. Hopefully we can use it next time
......@@ -2228,8 +2223,6 @@ class gpload:
sql += "(%s) "% formatOpts
if encodingStr:
sql += "encoding%s "%quote(encodingStr)
if self.error_table:
sql += "log errors into %s " % self.error_table
if self.log_errors:
sql += "log errors "
......@@ -2332,12 +2325,9 @@ class gpload:
def count_errors(self):
notice_processor(self)
if (self.error_table or self.log_errors) and not self.options.D and not self.reuse_tables:
if self.log_errors and not self.options.D and not self.reuse_tables:
# make sure we only get errors for our own instance
if self.error_table:
queryStr = 'select count(*) from ' + self.error_table + " WHERE relname = '%s'" % self.extTableName
else:
queryStr = "select count(*) from gp_read_error_log('%s')" %self.extTableName
queryStr = "select count(*) from gp_read_error_log('%s')" % pg.escape_string(self.extTableName)
results = self.db.query(queryStr.encode('utf-8')).getresult()
return (results[0])[0]
return 0
......@@ -2582,15 +2572,10 @@ class gpload:
# Is the table to be truncated before the load?
preload = self.getconfig('gpload:preload', list, default=None)
method = self.getconfig('gpload:output:mode', unicode, 'insert').lower()
self.error_table = self.getconfig('gpload:input:error_table', unicode, None)
self.log_errors = self.getconfig('gpload:input:log_errors', bool, False)
if self.error_table and self.log_errors:
self.control_file_error("gpload:input:log_errors and gpload:input:error_table are not allowd to use together.")
truncate = False
self.reuse_tables = False
self.error_table_oid = self.get_table_oid(self.error_table)
if not self.options.no_auto_trans and not method=='insert':
self.db.query("BEGIN")
......
......@@ -106,18 +106,6 @@ Feature: gpload tests
| count |
| 1 |
@gpload_reuse_errtbl
Scenario: gpload reuse external table as error table name is case insensitive
Given the database is running
And the database "testdb" does not exist
And database "testdb" exists
When the user runs the query "create table tbl1 (id int, msg text) distributed by (id)" on "testdb"
And the user runs command "gpload -f gppylib/test/behave/mgmt_utils/steps/data/gpload_reuse_ext_errtbl_1.yml"
Then the client program should print did not find an external table to reuse to stdout
When the user runs command "gpload -f gppylib/test/behave/mgmt_utils/steps/data/gpload_reuse_ext_errtbl_2.yml"
Then the client program should print reusing external table to stdout
@gpload_target_not_exist
Scenario: gpload output error message when target table not exists
Given the database is running
......
VERSION: 1.0.0.1
DATABASE: testdb
GPLOAD:
INPUT:
- SOURCE:
PORT_RANGE: [20000, 30000]
FILE:
- gppylib/test/behave/mgmt_utils/steps/data/gpload_reuse_ext.csv
- COLUMNS:
- id: int
- msg: text
- FORMAT: csv
- QUOTE: '"'
- ERROR_LIMIT: 9999
- ERROR_TABLE: public.eRrtAb2
OUTPUT:
- TABLE: tbl1
- MODE: merge
- MATCH_COLUMNS:
- id
- UPDATE_COLUMNS:
- msg
- MAPPING:
id: id
msg: msg
PRELOAD:
- REUSE_TABLES: true
VERSION: 1.0.0.1
DATABASE: testdb
GPLOAD:
INPUT:
- SOURCE:
PORT_RANGE: [20000, 30000]
FILE:
- gppylib/test/behave/mgmt_utils/steps/data/gpload_reuse_ext.csv
- COLUMNS:
- id: int
- msg: text
- FORMAT: csv
- QUOTE: '"'
- ERROR_LIMIT: 9999
- ERROR_TABLE: errtab2
OUTPUT:
- TABLE: tbl1
- MODE: merge
- MATCH_COLUMNS:
- id
- UPDATE_COLUMNS:
- msg
- MAPPING:
id: id
msg: msg
PRELOAD:
- REUSE_TABLES: true
......@@ -47,12 +47,8 @@ class GpLoadTestCase(unittest.TestCase):
gploader.read_config()
gploader.locations = [ 'gpfdist://localhost:8080/test' ]
rejectLimit = '9999'
errTableOid = 12345
sql = gploader.get_reuse_exttable_query('csv', 'header', rejectLimit, errTableOid, {}, None, False)
self.assertTrue('12345' in sql)
self.assertTrue(rejectLimit in sql)
sql = gploader.get_reuse_exttable_query('csv', 'header', None, None, {}, None, False)
sql = gploader.get_reuse_exttable_query('csv', 'header', None, {}, None, False)
self.assertTrue('pgext.fmterrtbl IS NULL' in sql)
self.assertTrue('pgext.rejectlimit IS NULL' in sql)
......
......@@ -15,7 +15,7 @@ GPLOAD:
- DELIMITER: ' ' # tab
- ERROR_LIMIT: 10
- ERROR_TABLE: dblp_errortable
- LOG_ERRORS: True
OUTPUT:
- TABLE: dblp_thesis
......
......@@ -16,7 +16,7 @@ GPLOAD:
- DELIMITER: '|'
- ERROR_LIMIT: 10
- ERROR_TABLE: mef_errortable
- LOG_ERRORS: True
OUTPUT:
- TABLE: mef_xml
......
......@@ -16,7 +16,7 @@ GPLOAD:
- DELIMITER: '|'
- ERROR_LIMIT: 10
- ERROR_TABLE: rig_errortable
- LOG_ERRORS: True
OUTPUT:
- TABLE: rig_xml
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册