[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2022-07-20 Thread Jing Zhang (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jing Zhang updated FLINK-24862:
---
Fix Version/s: 1.14.6

> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hive
>Affects Versions: 1.11.0, 1.12.0, 1.13.0, 1.14.0
>Reporter: xiangqiao
>Assignee: xiangqiao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.15.0, 1.14.6
>
> Attachments: image-2021-11-10-20-55-11-988.png, 
> image-2021-11-10-21-04-32-660.png
>
>
> When hive udaf/udtf is used, a validate exception is thrown ,i added a unit 
> test in HiveDialectITCase to reproduce this question:
> {code:java}
> @Test
> public void testTemporaryFunctionUDAF() throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_count as '%s'",
> GenericUDAFCount.class.getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_count"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x int)");
> tableEnv.executeSql("insert into src values (1),(-1)").await();
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_count");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-20-55-11-988.png|width=1363,height=282!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-12-15 Thread Jing Zhang (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jing Zhang updated FLINK-24862:
---
Affects Version/s: 1.12.0
   1.11.0

> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hive
>Affects Versions: 1.11.0, 1.12.0, 1.13.0, 1.14.0
>Reporter: xiangqiao
>Assignee: xiangqiao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.15.0
>
> Attachments: image-2021-11-10-20-55-11-988.png, 
> image-2021-11-10-21-04-32-660.png
>
>
> When hive udaf/udtf is used, a validate exception is thrown ,i added a unit 
> test in HiveDialectITCase to reproduce this question:
> {code:java}
> @Test
> public void testTemporaryFunctionUDAF() throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_count as '%s'",
> GenericUDAFCount.class.getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_count"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x int)");
> tableEnv.executeSql("insert into src values (1),(-1)").await();
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_count");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-20-55-11-988.png|width=1363,height=282!



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-12-15 Thread Jing Zhang (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jing Zhang updated FLINK-24862:
---
Fix Version/s: 1.15.0

> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hive
>Affects Versions: 1.13.0, 1.14.0
>Reporter: xiangqiao
>Assignee: xiangqiao
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.15.0
>
> Attachments: image-2021-11-10-20-55-11-988.png, 
> image-2021-11-10-21-04-32-660.png
>
>
> When hive udaf/udtf is used, a validate exception is thrown ,i added a unit 
> test in HiveDialectITCase to reproduce this question:
> {code:java}
> @Test
> public void testTemporaryFunctionUDAF() throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_count as '%s'",
> GenericUDAFCount.class.getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_count"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x int)");
> tableEnv.executeSql("insert into src values (1),(-1)").await();
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_count");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-20-55-11-988.png|width=1363,height=282!



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-12-02 Thread xiangqiao (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiangqiao updated FLINK-24862:
--
Description: 
When hive udaf/udtf is used, a validate exception is thrown ,i added a unit 
test in HiveDialectITCase to reproduce this question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png|width=1363,height=282!

  was:
Here are two questions:
1.First question, I added a unit test in HiveDialectITCase to reproduce this 
question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png!

2.When I solved the first problem, I met the second problem,I added a unit test 
in HiveDialectITCase to reproduce this question:

This is the compatibility of hive udtf. Refer to this 
issue:https://issues.apache.org/jira/browse/HIVE-5737
{code:java}
@Test
public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_split as '%s'",

HiveGenericUDTFTest.TestSplitUDTFInitializeWithStructObjectInspector.class
.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_split"}, functions);
// call the function
tableEnv.executeSql("create table src(x string)");
tableEnv.executeSql("insert into src values ('a,b,c')").await();
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_split");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-21-04-32-660.png!


> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue 

[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-11-10 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated FLINK-24862:
---
Labels: pull-request-available  (was: )

> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hive
>Affects Versions: 1.13.0, 1.14.0
>Reporter: xiangqiao
>Priority: Major
>  Labels: pull-request-available
> Attachments: image-2021-11-10-20-55-11-988.png, 
> image-2021-11-10-21-04-32-660.png
>
>
> Here are two questions:
> 1.First question, I added a unit test in HiveDialectITCase to reproduce this 
> question:
> {code:java}
> @Test
> public void testTemporaryFunctionUDAF() throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_count as '%s'",
> GenericUDAFCount.class.getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_count"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x int)");
> tableEnv.executeSql("insert into src values (1),(-1)").await();
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_count");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-20-55-11-988.png!
> 2.When I solved the first problem, I met the second problem,I added a unit 
> test in HiveDialectITCase to reproduce this question:
> This is the compatibility of hive udtf. Refer to this 
> issue:https://issues.apache.org/jira/browse/HIVE-5737
> {code:java}
> @Test
> public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
> throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_split as '%s'",
> 
> HiveGenericUDTFTest.TestSplitUDTFInitializeWithStructObjectInspector.class
> .getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_split"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x string)");
> tableEnv.executeSql("insert into src values ('a,b,c')").await();
> assertEquals(
> "[+I[a], +I[b], +I[c]]",
> queryResult(tableEnv.sqlQuery("select temp_split(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[a], +I[b], +I[c]]",
> queryResult(tableEnv.sqlQuery("select temp_split(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_split");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-21-04-32-660.png!



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-11-10 Thread xiangqiao (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiangqiao updated FLINK-24862:
--
Description: 
Here are two questions:
1.First question, I added a unit test in HiveDialectITCase to reproduce this 
question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png!

2.When I solved the first problem, I met the second problem,I added a unit test 
in HiveDialectITCase to reproduce this question:

This is the compatibility of hive udtf. Refer to this 
issue:https://issues.apache.org/jira/browse/HIVE-5737
{code:java}
@Test
public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_split as '%s'",

HiveGenericUDTFTest.TestSplitUDTFInitializeWithStructObjectInspector.class
.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_split"}, functions);
// call the function
tableEnv.executeSql("create table src(x string)");
tableEnv.executeSql("insert into src values ('a,b,c')").await();
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_split");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-21-04-32-660.png!

  was:
Here are two questions:
1.First question, I added a unit test in HiveDialectITCase to reproduce this 
question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png!

2.When I solved the first problem, I met the second problem,I added a unit test 
in HiveDialectITCase to reproduce this question:

This is the compatibility of hive udtf. Refer to this 
issue:https://issues.apache.org/jira/browse/HIVE-5737
{code:java}
@Test
public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
throws Excep

[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-11-10 Thread xiangqiao (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiangqiao updated FLINK-24862:
--
Attachment: image-2021-11-10-21-04-32-660.png

> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hive
>Affects Versions: 1.13.0, 1.14.0
>Reporter: xiangqiao
>Priority: Major
> Attachments: image-2021-11-10-20-55-11-988.png, 
> image-2021-11-10-21-04-32-660.png
>
>
> Here are two questions:
> 1.First question, I added a unit test in HiveDialectITCase to reproduce this 
> question:
> {code:java}
> @Test
> public void testTemporaryFunctionUDAF() throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_count as '%s'",
> GenericUDAFCount.class.getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_count"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x int)");
> tableEnv.executeSql("insert into src values (1),(-1)").await();
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[2]]",
> queryResult(tableEnv.sqlQuery("select temp_count(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_count");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
> !image-2021-11-10-20-55-11-988.png!
> 2.When I solved the first problem, I met the second problem,I added a unit 
> test in HiveDialectITCase to reproduce this question:
> This is the compatibility of hive udtf. Refer to this 
> issue:https://issues.apache.org/jira/browse/HIVE-5737
> {code:java}
> @Test
> public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
> throws Exception {
> // create temp function
> tableEnv.executeSql(
> String.format(
> "create temporary function temp_split as '%s'",
> 
> HiveGenericUDTFTest.TestSplitUDTFInitializeWithStructObjectInspector.class
> .getName()));
> String[] functions = tableEnv.listUserDefinedFunctions();
> assertArrayEquals(new String[] {"temp_split"}, functions);
> // call the function
> tableEnv.executeSql("create table src(x string)");
> tableEnv.executeSql("insert into src values ('a,b,c')").await();
> assertEquals(
> "[+I[a], +I[b], +I[c]]",
> queryResult(tableEnv.sqlQuery("select temp_split(x) from 
> src")).toString());
> // switch DB and the temp function can still be used
> tableEnv.executeSql("create database db1");
> tableEnv.useDatabase("db1");
> assertEquals(
> "[+I[a], +I[b], +I[c]]",
> queryResult(tableEnv.sqlQuery("select temp_split(x) from 
> `default`.src"))
> .toString());
> // drop the function
> tableEnv.executeSql("drop temporary function temp_split");
> functions = tableEnv.listUserDefinedFunctions();
> assertEquals(0, functions.length);
> tableEnv.executeSql("drop temporary function if exists foo");
> } {code}
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (FLINK-24862) The user-defined hive udaf/udtf cannot be used normally in hive dialect

2021-11-10 Thread xiangqiao (Jira)


 [ 
https://issues.apache.org/jira/browse/FLINK-24862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

xiangqiao updated FLINK-24862:
--
Description: 
Here are two questions:
1.First question, I added a unit test in HiveDialectITCase to reproduce this 
question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png!

2.When I solved the first problem, I met the second problem,I added a unit test 
in HiveDialectITCase to reproduce this question:

This is the compatibility of hive udtf. Refer to this 
issue:https://issues.apache.org/jira/browse/HIVE-5737
{code:java}
@Test
public void testTemporaryFunctionUDTFInitializeWithStructObjectInspector() 
throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_split as '%s'",

HiveGenericUDTFTest.TestSplitUDTFInitializeWithStructObjectInspector.class
.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_split"}, functions);
// call the function
tableEnv.executeSql("create table src(x string)");
tableEnv.executeSql("insert into src values ('a,b,c')").await();
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[a], +I[b], +I[c]]",
queryResult(tableEnv.sqlQuery("select temp_split(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_split");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
 

 

 

 

 

 

 

 

 

 

  was:
Here are two questions:
1.First question, I added a unit test in HiveDialectITCase to reproduce this 
question:
{code:java}
@Test
public void testTemporaryFunctionUDAF() throws Exception {
// create temp function
tableEnv.executeSql(
String.format(
"create temporary function temp_count as '%s'",
GenericUDAFCount.class.getName()));
String[] functions = tableEnv.listUserDefinedFunctions();
assertArrayEquals(new String[] {"temp_count"}, functions);
// call the function
tableEnv.executeSql("create table src(x int)");
tableEnv.executeSql("insert into src values (1),(-1)").await();
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
src")).toString());
// switch DB and the temp function can still be used
tableEnv.executeSql("create database db1");
tableEnv.useDatabase("db1");
assertEquals(
"[+I[2]]",
queryResult(tableEnv.sqlQuery("select temp_count(x) from 
`default`.src"))
.toString());
// drop the function
tableEnv.executeSql("drop temporary function temp_count");
functions = tableEnv.listUserDefinedFunctions();
assertEquals(0, functions.length);
tableEnv.executeSql("drop temporary function if exists foo");
} {code}
!image-2021-11-10-20-55-11-988.png!


> The user-defined hive udaf/udtf cannot be used normally in hive dialect
> ---
>
> Key: FLINK-24862
> URL: https://issues.apache.org/jira/browse/FLINK-24862
> Project: Flink
>  Issue Type: Bug
>  Components: Connectors / Hi