apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.34k stars 3.21k forks source link

[Bug] Power BI连接报错,输入字符串的格式不正确 #21098

Open g-sun opened 1 year ago

g-sun commented 1 year ago

Search before asking

Version

1.2.5

What's Wrong?

使用Power BI Desktop 23年5月版+MySQL Connector/NET 8.0.28连接doris服务器,连接时报错,Power BI日志中可以看到

Message: Input string was not in a correct format.
StackTrace:
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at MySql.Data.MySqlClient.Driver.LoadCharacterSets(MySqlConnection connection)
   at MySql.Data.MySqlClient.Driver.Configure(MySqlConnection connection)
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at Microsoft.Mashup.Engine1.Library.Common.TracingDbConnection.<Open>b__5_0(IHostTrace trace)
   at Microsoft.Mashup.Engine1.Library.Common.Tracer.<>c__DisplayClass19_0.<TracePerformance>b__0(IHostTrace trace)
   at Microsoft.Mashup.Engine1.Library.Common.Tracer.TracePerformance[T](String method, Func`2 func)

Exception:
ExceptionType: System.FormatException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message: Input string was not in a correct format.
StackTrace:
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at MySql.Data.MySqlClient.Driver.LoadCharacterSets(MySqlConnection connection)
   at MySql.Data.MySqlClient.Driver.Configure(MySqlConnection connection)
   at MySql.Data.MySqlClient.MySqlConnection.Open()
   at Microsoft.Mashup.Engine1.Library.Common.TracingDbConnection.<Open>b__5_0(IHostTrace trace)
   at Microsoft.Mashup.Engine1.Library.Common.Tracer.<>c__DisplayClass19_0.<TracePerformance>b__0(IHostTrace trace)
   at Microsoft.Mashup.Engine1.Library.Common.Tracer.TracePerformance[T](String method, Func`2 func)
   at Microsoft.Mashup.Engine1.Library.Common.TracingDbConnection.Open()
   at Microsoft.Mashup.Engine1.Library.Common.WrappedDbConnection.Open()
   at Microsoft.Mashup.Engine1.Library.Common.DbExtensions.<>c__DisplayClass0_0.<Open>b__0()
   at Microsoft.Mashup.Engine1.Library.Common.DbEnvironment.RunWithRetryGuard[T](Func`1 action, Func`2 retryAfterSqlError, Action finalizeOnRetry, String dataSourceNameString, IEngineHost host, IResource resource)
   at Microsoft.Mashup.Engine1.Library.Common.DbEnvironment.ConvertDbExceptions[T](IResource resource, Func`1 action, Func`2 retryAfterSqlError, Action finalizeOnRetry, String dataSourceNameString, IEngineHost host)

What You Expected?

正常加载数据

How to Reproduce?

错误出现在MySQL.Data的Driver.cs,https://github.com/mysql/mysql-connector-net/blob/8.0.28/MySQL.Data/src/Driver.cs#L345 。 对autocommit的值Ture进行Convert.ToInt32时出现错误。 抓包发现返回值是1,但列类型是FIELD_TYPE_TINY,而MySQL对应列类型是FIELD_TYPE_LONGLONG。 导致这个问题的原因是 https://github.com/mysql/mysql-connector-net/blob/8.0.28/MySQL.Data/src/Field.cs#L275

Anything Else?

Driver.cs中相关代码是8.0.27新增,所以这个问题的解决方法有几种:

  1. Doris修改autocommit列类型,这个也符合兼容MySQL协议的思路。
  2. Power BI使用8.0.27以前的mysql client,这个需要微软调整相关文档。但Power BI/MySQL/Doris都在发展,一直使用旧版本不是最好的思路。
  3. Power BI连接时修改代码增加TreatTinyAsBoolean设置( https://learn.microsoft.com/zh-cn/powerquery-m/mysql-database ),但这个需要对M语言有一定的了解才可以,具备这个能力的用户在Power BI用户群中占比很低,也不是很现实。

很希望可以提交PR,但对Doris代码不熟悉,可能无能为力。

Are you willing to submit PR?

Code of Conduct

Zhangyue168 commented 1 year ago

谢谢大佬的回复,解决了我现在的问题。采用了的第三种解决方案,数据已成功加载(在Power BI Desktop中)