You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by 肖越 <18...@163.com> on 2021/01/27 09:43:42 UTC

pyflink1.11 table.to_pandas() 报错 'Sort on a non-time-attribute field is not supported.'

通过sql_query执行返回table对象,执行table.to_pandas()报错:
Traceback (most recent call last):
  File "C:/projects/dataService-pyflink_explore/dataService-calculate-code-python/src/test/test_mysql_connector.py", line 161, in <module>
    print(table.to_pandas().head(6))
  File "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\pyflink\table\table.py", line 723, in to_pandas
    .collectAsPandasDataFrame(self._j_table, max_arrow_batch_size)
  File "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\py4j\java_gateway.py", line 1286, in __call__
    answer, self.gateway_client, self.target_id, self.name)
  File "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\pyflink\util\exceptions.py", line 154, in deco
    raise exception_mapping[exception](s.split(': ', 1)[1], stack_trace)
pyflink.util.exceptions.TableException: 'Sort on a non-time-attribute field is not supported.'
请教各位大佬,为什么会转换失败?但表格本身print_schema是没问题的。

Re: pyflink1.11 table.to_pandas() 报错 'Sort on a non-time-attribute field is not supported.'

Posted by Xingbo Huang <hx...@gmail.com>.
看报错你是调用了order_by操作吧。对于unbounded
table来说,order_by只能作用在时间字段上,要不然就得后面接上fetch操作。具体可以参考文档[1]

[1]
https://ci.apache.org/projects/flink/flink-docs-master/dev/table/tableApi.html#orderby-offset--fetch

Best,
Xingbo

肖越 <18...@163.com> 于2021年1月27日周三 下午5:44写道:

> 通过sql_query执行返回table对象,执行table.to_pandas()报错:
> Traceback (most recent call last):
>   File
> "C:/projects/dataService-pyflink_explore/dataService-calculate-code-python/src/test/test_mysql_connector.py",
> line 161, in <module>
>     print(table.to_pandas().head(6))
>   File
> "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\pyflink\table\table.py",
> line 723, in to_pandas
>     .collectAsPandasDataFrame(self._j_table, max_arrow_batch_size)
>   File
> "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\py4j\java_gateway.py",
> line 1286, in __call__
>     answer, self.gateway_client, self.target_id, self.name)
>   File
> "C:\Users\18242\AppData\Local\Programs\Python\Python37\lib\site-packages\pyflink\util\exceptions.py",
> line 154, in deco
>     raise exception_mapping[exception](s.split(': ', 1)[1], stack_trace)
> pyflink.util.exceptions.TableException: 'Sort on a non-time-attribute
> field is not supported.'
> 请教各位大佬,为什么会转换失败?但表格本身print_schema是没问题的。