You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by xm lian <li...@gmail.com> on 2021/08/24 11:56:33 UTC

how to read data from hive table using flink sqlclent?

0
<https://stackoverflow.com/posts/68907086/timeline>

I tried to read the data from hive table using the flink sql client as per
the flink documentation
<https://ci.apache.org/projects/flink/flink-docs-master/docs/connectors/table/hive/hive_catalog/>
but
it failed. i can read the table meta information,but not the data.
here is my hive data:

```shell

0: jdbc:hive2://localhost:10000> create database testdb ;
No rows affected (2.048 seconds)
0: jdbc:hive2://localhost:10000> use testdb ;
No rows affected (0.106 seconds)
0: jdbc:hive2://localhost:10000> create table source (a bigint, b bigint) ;
No rows affected (1.026 seconds)
0: jdbc:hive2://localhost:10000> show tables ;
+-----------+--+
| tab_name  |
+-----------+--+
| source    |
+-----------+--+
1 row selected (0.877 seconds)
0: jdbc:hive2://localhost:10000> insert into source values (1, 1) ;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available
in the future versions. Consider using a different execution engine
(i.e. tez, spark) or using Hive 1.X releases.
No rows affected (7.498 seconds)
0: jdbc:hive2://localhost:10000> select a, b from source ;
+----+----+--+
| a  | b  |
+----+----+--+
| 1  | 1  |
+----+----+--+

```

here is my flink sql client:

```shell

Flink SQL> show catalogs ;
+-----------------+
|    catalog name |
+-----------------+
| default_catalog |
|          myhive |
+-----------------+
2 rows in set

Flink SQL> use catalog myhive ;
[INFO] Execute statement succeed.

Flink SQL> show databases ;
+---------------+
| database name |
+---------------+
|       default |
|        testdb |
+---------------+
2 rows in set

Flink SQL> use testdb ;
[INFO] Execute statement succeed.

Flink SQL> show tables ;
+------------+
| table name |
+------------+
|     source |
+------------+
1 row in set

Flink SQL> SET sql-client.execution.result-mode=tableau;
[INFO] Session property has been set.

Flink SQL> select a, b from source ;
Empty set

```

I have added a new project to quickly reproduce this error:
https://github.com/lianxmfor/flink-hive

Re: how to read data from hive table using flink sqlclent?

Posted by xm lian <li...@gmail.com>.
I have added a new project to quickly reproduce this error:
https://github.com/lianxmfor/flink-hive

xm lian <li...@gmail.com> 于2021年8月24日周二 下午7:56写道:

> 0
> <https://stackoverflow.com/posts/68907086/timeline>
>
> I tried to read the data from hive table using the flink sql client as per
> the flink documentation
> <https://ci.apache.org/projects/flink/flink-docs-master/docs/connectors/table/hive/hive_catalog/> but
> it failed. i can read the table meta information,but not the data.
> here is my hive data:
>
> ```shell
>
> 0: jdbc:hive2://localhost:10000> create database testdb ;
> No rows affected (2.048 seconds)
> 0: jdbc:hive2://localhost:10000> use testdb ;
> No rows affected (0.106 seconds)
> 0: jdbc:hive2://localhost:10000> create table source (a bigint, b bigint) ;
> No rows affected (1.026 seconds)
> 0: jdbc:hive2://localhost:10000> show tables ;
> +-----------+--+
> | tab_name  |
> +-----------+--+
> | source    |
> +-----------+--+
> 1 row selected (0.877 seconds)
> 0: jdbc:hive2://localhost:10000> insert into source values (1, 1) ;
> WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. tez, spark) or using Hive 1.X releases.
> No rows affected (7.498 seconds)
> 0: jdbc:hive2://localhost:10000> select a, b from source ;
> +----+----+--+
> | a  | b  |
> +----+----+--+
> | 1  | 1  |
> +----+----+--+
>
> ```
>
> here is my flink sql client:
>
> ```shell
>
> Flink SQL> show catalogs ;
> +-----------------+
> |    catalog name |
> +-----------------+
> | default_catalog |
> |          myhive |
> +-----------------+
> 2 rows in set
>
> Flink SQL> use catalog myhive ;
> [INFO] Execute statement succeed.
>
> Flink SQL> show databases ;
> +---------------+
> | database name |
> +---------------+
> |       default |
> |        testdb |
> +---------------+
> 2 rows in set
>
> Flink SQL> use testdb ;
> [INFO] Execute statement succeed.
>
> Flink SQL> show tables ;
> +------------+
> | table name |
> +------------+
> |     source |
> +------------+
> 1 row in set
>
> Flink SQL> SET sql-client.execution.result-mode=tableau;
> [INFO] Session property has been set.
>
> Flink SQL> select a, b from source ;
> Empty set
>
> ```
>
> I have added a new project to quickly reproduce this error: https://github.com/lianxmfor/flink-hive
>
>