PowerBI直接查询连接到PostgreSQL错误。 OLE或ODBC错误:[Expression.Error]我们无法将表达式折叠到数据源

时间:2018-05-21 07:56:30

标签: postgresql odbc powerbi

根据Microsoft DataConnectors的信息,我想使用直接查询,通过this ODBC driver创建从PowerBi到PostgreSQL的连接器。我重用了Microsoft sample中的代码,只调整了ConnectionString,没有别的。 在构建我导入PowerBI的.mez文件后,我想连接到PostgreSQL服务器。 This is how the connection dialog looks like。连接成功,我可以在DB中查看表并使用它们。现在,问题出现在这里:当我选择一些列来显示表格或图表中的数据时,我得到OLE or ODBC error: [Expression.Error] We couldn't fold the expression to the data source。我还在诊断选项中启用了跟踪,因此这里是日志内容:

DataMashup.TraceWarning: 24579:
    "Start": "2018-05-18T10:51:56.6199845Z",
    "Action": "OdbcQuery/FoldingWarning",
    "HostProcessId": "25020",
    "Function Name": "Group",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "f06a4b5b-09ba-40ce-bd99-424710286b77",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 1,
    "Duration": "00:00:00.0000051"
DataMashup.TraceInformation: 24579: 
    "Start": "2018-05-18T10:51:56.6199552Z",
    "Action": "BackgroundThread/RollingTraceWriter/Flush",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "00000000-0000-0000-0000-000000000000",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 8,
    "Duration": "00:00:00.0000560"
DataMashup.TraceWarning: 24579: 
    "Start": "2018-05-18T10:51:56.6199999Z",
    "Action": "OdbcQuery/FoldingWarning",
    "HostProcessId": "25020",
    "ErrorMessage": "This ODBC driver doesn't set the GroupByCapabilities feature. You can override it by using SqlCapabilities.",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "f06a4b5b-09ba-40ce-bd99-424710286b77",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 1,
    "Duration": "00:00:00.0000159"
DataMashup.TraceInformation: 24579: 
    "Start": "2018-05-18T10:51:56.6200385Z",
    "Action": "BackgroundThread/RollingTraceWriter/Flush",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "00000000-0000-0000-0000-000000000000",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 9,
    "Duration": "00:00:00.0000215"
DataMashup.TraceWarning: 24579: 
    "Start": "2018-05-18T10:51:56.6201305Z",
    "Action": "OdbcQueryDomain/ReportFoldingFailure",
    "HostProcessId": "25020",
    "Exception": "Exception:\r\nExceptionType: Microsoft.Mashup.Engine1.Runtime.FoldingFailureException, Microsoft.MashupEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nMessage: Folding failed. Please take a look the information in the trace.\r\nStackTrace:\n   at Microsoft.Mashup.Engine1.Library.Odbc.OdbcQuery.Group(Grouping grouping)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.VisitQuery(Query query, Func`2 operation)\r\n\r\n\r\n",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "f06a4b5b-09ba-40ce-bd99-424710286b77",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 1,
    "Duration": "00:00:00.0000504"
DataMashup.TraceInformation: 24579: 
    "Start": "2018-05-18T10:51:56.6202107Z",
    "Action": "BackgroundThread/RollingTraceWriter/Flush",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "00000000-0000-0000-0000-000000000000",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 8,
    "Duration": "00:00:00.0000154"
DataMashup.TraceWarning: 24579: 
    "Start": "2018-05-18T10:51:56.6199413Z",
    "Action": "RemotePageReader/RunStub",
    "HostProcessId": "25020",
    "Exception": "Exception:\r\nExceptionType: Microsoft.Mashup.Engine1.Runtime.ValueException, Microsoft.MashupEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\r\nMessage: [Expression.Error] We couldn't fold the expression to the data source. Please try a simpler expression.\r\nStackTrace:\n   at Microsoft.Mashup.Engine1.Library.Odbc.OdbcQueryDomain.ReportFoldingFailure(NotSupportedException ex)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.VisitQuery(Query query, Func`2 operation)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.VisitQuery(Query query)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.VisitQuery(Query query, Func`2 operation)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.VisitQuery(Query query)\r\n   at Microsoft.Mashup.Engine1.Runtime.OptimizingQueryVisitor.Optimize(Query query)\r\n   at Microsoft.Mashup.Engine1.Language.Query.QueryTableValue.get_OptimizedQuery()\r\n   at Microsoft.Mashup.Engine1.Language.Query.QueryTableValue.GetReader()\r\n   at Microsoft.Mashup.Engine.Interface.Tracing.TracingDataReaderSource.get_PageReader()\r\n   at Microsoft.Mashup.Evaluator.RemoteDocumentEvaluator.Service.c__DisplayClass11.c__DisplayClass13.b__10()\r\n   at Microsoft.Mashup.Evaluator.RemotePageReader.c__DisplayClass7.b__0()\r\n   at Microsoft.Mashup.Evaluator.EvaluationHost.ReportExceptions(IHostTrace trace, IEngineHost engineHost, IMessageChannel channel, Action action)\r\n\r\n\r\n",
    "ProductVersion": "2.58.5103.501 (PBIDesktop)",
    "ActivityId": "f06a4b5b-09ba-40ce-bd99-424710286b77",
    "Process": "Microsoft.Mashup.Container.NetFX40",
    "Pid": 11080,
    "Tid": 1,
    "Duration": "00:00:00.0005557"

有任何想法如何解决此错误? 感谢

1 个答案:

答案 0 :(得分:3)

今天我才第一次使用Direct Query存储模式连接到PostgreSQL,并且也遇到了此错误。像您一样,连接和其他所有东西似乎都可以正常工作,但是当尝试使用在使用“导入”存储模式时可以正常工作的视觉效果时,便抛出了错误。

我的错误显示为:OLE DB or ODBC error: [Expression.Error] We couldn't fold the expression to the data source. Please try a simpler expression.我认为最后一句话是在更高版本的Power BI中添加的。

Carl de Souza解释了查询折叠here,并且看来直接查询尝试将尽可能多的分析折叠到本机查询中。初次提取数据时我没有指定任何查询,但是一旦执行该错误就消失了。

对于任何不知道如何执行此操作的用户,请单击“获取数据”(如果已经在查询编辑器中,则单击“新建源”)并选择PostreSQL数据库,请确保在“高级”选项中添加SQL语句。部分。

对我来说,一个简单的      SELECT * FROM my_schema."my_table_name" 足够。

Sample filling out of the PostgreSQL database popup