This is an automated email from the ASF dual-hosted git repository.
ztao1987 pushed a commit to branch ztao
in repository https://gitbox.apache.org/repos/asf/hawq.git
The following commit(s) were added to refs/heads/ztao by this push:
new 1aa69cf HAWQ-1832. fix ORC bloom filter option
1aa69cf is described below
commit 1aa69cf398f49760b2f3d58f2c02200f02cdae6c
Author: ztao1987 <[email protected]>
AuthorDate: Thu Feb 24 23:24:55 2022 +0800
HAWQ-1832. fix ORC bloom filter option
---
contrib/orc/orc.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/contrib/orc/orc.c b/contrib/orc/orc.c
index 3dfda32..8e45c1c 100644
--- a/contrib/orc/orc.c
+++ b/contrib/orc/orc.c
@@ -136,7 +136,7 @@ static void init_format_user_data_for_write(TupleDesc
tup_desc,
static void build_options_in_json(List *fmt_opts_defelem, int encoding,
char **json_str, TupleDesc tupDesc);
static ORCFormatC *create_formatter_instance(List *fmt_opts_defelem,
- int encoding, int segno, TupleDesc tupDesc);
+ int encoding, int segno, TupleDesc tupDesc, bool forWrite);
static void build_file_splits(Uri *uri, ScanState *scan_state,
ORCFormatUserData *user_data);
static void build_tuple_descrition_for_read(Plan *plan, Relation relation,
@@ -617,7 +617,7 @@ Datum orc_beginscan(PG_FUNCTION_ARGS)
/* 3.2 Create formatter instance */
List *fmt_opts_defelem = pstate->custom_formatter_params;
user_data->fmt = create_formatter_instance(fmt_opts_defelem,
fmt_encoding,
- ps->ps_segno, tup_desc);
+ ps->ps_segno, tup_desc, false);
/* 3.3 Build file splits */
Uri *uri = ParseExternalTableUri(uri_str);
@@ -841,7 +841,7 @@ Datum orc_rescan(PG_FUNCTION_ARGS)
List *fmt_opts_defelem =
fsd->fs_pstate->custom_formatter_params;
int fmt_encoding = fsd->fs_pstate->client_encoding;
user_data->fmt = create_formatter_instance(fmt_opts_defelem,
- fmt_encoding, ps->ps_segno, tup_desc);
+ fmt_encoding, ps->ps_segno, tup_desc, false);
/* 3 Build file splits */
Uri *uri = ParseExternalTableUri(fsd->fs_uri);
@@ -1251,7 +1251,7 @@ Datum orc_insert_init(PG_FUNCTION_ARGS)
/* 2.2 Create formatter instance */
List *fmt_opts_defelem = pstate->custom_formatter_params;
user_data->fmt = create_formatter_instance(fmt_opts_defelem,
fmt_encoding,
- ps->ps_segno, tup_desc);
+ ps->ps_segno, tup_desc, true);
/* 2.4 Build tuple description */
build_tuple_descrition_for_write(relation, user_data);
@@ -1706,7 +1706,7 @@ static void build_options_in_json(List *fmt_opts_defelem,
int encoding,
{
if ((strncasecmp(token, ((Form_pg_attribute)
(tupDesc->attrs[j]))->attname.data, strlen(token)) == 0))
{
- json_object *j_obj = json_object_new_int(j);
+ json_object *j_obj = json_object_new_int(j + 1);
json_object_array_add(j_array, j_obj);
}
}
@@ -1746,13 +1746,17 @@ static void build_options_in_json(List
*fmt_opts_defelem, int encoding,
}
static ORCFormatC *create_formatter_instance(List *fmt_opts_defelem,
- int fmt_encoding, int segno, TupleDesc tupDesc)
+ int fmt_encoding, int segno, TupleDesc tupDesc, bool forWrite)
{
char *fmt_opts_str = NULL;
- build_options_in_json(fmt_opts_defelem, fmt_encoding, &fmt_opts_str,
tupDesc);
-
- ORCFormatC *orc_format_c = ORCFormatNewORCFormatC(fmt_opts_str, segno);
+ ORCFormatC *orc_format_c = NULL;
+ if (forWrite) {
+ build_options_in_json(fmt_opts_defelem, fmt_encoding,
&fmt_opts_str, tupDesc);
+ orc_format_c = ORCFormatNewORCFormatC(fmt_opts_str, segno);
+ } else {
+ orc_format_c = ORCFormatNewORCFormatC("{}", segno);
+ }
if (fmt_opts_str != NULL)
{