You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @yanye666, is this the issue we discussed on Telegram? You can update your query to use parseDateTimeBestEffort or clean up values expression(e.g. insert into table values(?,now(),?) -> insert into table(a,c) values(?,?)), so that JDBC driver can infer table schema automatically.
Hi @yanye666, is this the issue we discussed on Telegram? You can update your query to use parseDateTimeBestEffort or clean up values expression(e.g. insert into table values(?,now(),?) -> insert into table(a,c) values(?,?)), so that JDBC driver can infer table schema automatically.
Can you customize insert query to use parseDateTimeBestEffort function as suggested above?
Nope, I have no control over the ETL code. It also failed on Data Value Lookup using PreparedStatement (workaround toString and create a view or ALIAS columns)
By the way, it's just my personal opinion, that Pentaho Kettle/Data Integration is a dying product, you'd better consider its successor Apache Hop.
100%, this is legacy code. Sending a java.util.Date to a Date field does not seem to be to crazy :-)
Can you customize insert query to use parseDateTimeBestEffort function as suggested above?
Nope, I have no control over the ETL code. It also failed on Data Value Lookup using PreparedStatement (workaround toString and create a view or ALIAS columns)
By the way, it's just my personal opinion, that Pentaho Kettle/Data Integration is a dying product, you'd better consider its successor Apache Hop.
100%, this is legacy code. Sending a It's crazy not to support java.util.Date It needs to be compatible with this type! to a Date field does not seem to be to crazy :-)
Not supporting java.util.Date is very violent, and this solution of invading SQL is not good.
Later, I will output an abnormal time type, which I have encountered in production, and I am very upset.
It also failed on Data Value Lookup using PreparedStatement (workaround toString and create a view or ALIAS columns)
That sounds really painful, any specific query you can share and I'll see if I can help.
Sending a java.util.Date to a Date field does not seem to be to crazy :-)
@aadant, hahaha, very true. The problem is on ClickHouse side. Since it does not support prepared statement like other databases, the JDBC driver has to figure out column types by itself. It either trusts the intention(in this case, java.util.Date is more suitable for DateTime64, not DateTime32 or Date), or try to infer parameter type by parsing the query(when input function or a clean values expression was used). Understood the query and parameters came from Kettle, but there's user defined Java/script step that you can leverage.
Not supporting java.util.Date is very violent, and this solution of invading SQL is not good.
Later, I will output an abnormal time type, which I have encountered in production, and I am very upset.
@yanye666, calm down and don't be sad. Sorry I could not answer all questions in time, as I only work on this project in my spare time. As to the issue, as I explained in above, due to various limitation, you'd better take a workaround instead of counting on a feature being implemented soon.
Sure, feel free to share more cases and I'll try to help.
This is me testing the entry between two versions of different types.
clickhouse version :22.1.3.7
notice:
in mybatis. mybatis has DateTypeHandler, which is implemented based on setTimeStamp, so java.util.Date is also supported in mybatis
Note Synchronize the time zone of the server
When running the test code, be aware that your clickhouse-server has a distributed cluster
After testing, restore the Settings stated above "date_time_input_format=best_effort", did not work? Is it because the clickhouse-server version has Higher @aadant@filimonov ?
Test
Remark
0.3.1
0.3.2-11patch
testDefault
The test uses the database default
✅
✅
testDefaultNull
Insert null to test the database default
✅
❌ java.sql.SQLException: Cannot set null to non-nullable column #2 [create_time DateTime]
testString
Test insert string
✅
✅
testTimeSecond
Test insert second
✅
❌ Time zone problem exists, org.junit.ComparisonFailure: Expected :2023-02-05 11:42:12 Actual :2023-02-05 19:42:12
Thank you @yanye666 for summarizing issues you ran into and providing testing code. Apologize getting back a bit late as I'm still trying to fix an issue I encountered during benchmark over the weekend.
testDefaultNull - this is caused by the data format change from TabSeparated to RowBinary(not only for performance but also resolving serialization and deserialization issues along with better timezone support), and the latter does not support specifying null for a non-nullable column - null_as_default option was added as a workaround for some but not all cases
testTimeSecond - this seems related to timezone. The legacy driver does not handle timezone very well.
testDate - is this the original issue? Let me see if I can enhance the driver a bit, but java.util.Date will be mapped to DateTime64 by default.
session locked - you may bump driver to 0.4.0 for the fix
insertDateBySelect - a few workarounds have been mentioned in above, changing user setting or even switching to DateTime64 will help
Since everyone else using mybatis will likely run into the same issues, are you willing to contribution a dialect or so to benefit more users?
Thanks Your summary and answer,
My test is divided into two parts, the one above is jdbc mode, and the one below is mybatis mode.
on 0.3.1. Inserting clickhouse directly through mybatis has very low performance. So I used jdbc primordial(I don't know if there is any improvement after the upgrade.), which is why I am mainly testing jdbc mode.
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
Activity
aadant commentedon Feb 3, 2023
I hit the same issue in an ETL tool called Pentaho
zhicwu commentedon Feb 3, 2023
Hi @yanye666, is this the issue we discussed on Telegram? You can update your query to use
parseDateTimeBestEffortor clean up values expression(e.g.insert into table values(?,now(),?)->insert into table(a,c) values(?,?)), so that JDBC driver can infer table schema automatically.zhicwu commentedon Feb 3, 2023
Can you customize insert query to use parseDateTimeBestEffort function as suggested above?
By the way, it's just my personal opinion, that Pentaho Kettle/Data Integration is a dying product, you'd better consider its successor Apache Hop.
yanye666 commentedon Feb 3, 2023
I just use
insert into table(a,c) values(?,?))
introduction java.util.date Error occurred
Telegram, you won't reply to me
aadant commentedon Feb 3, 2023
Nope, I have no control over the ETL code. It also failed on Data Value Lookup using PreparedStatement (workaround toString and create a view or ALIAS columns)
100%, this is legacy code. Sending a java.util.Date to a Date field does not seem to be to crazy :-)
yanye666 commentedon Feb 3, 2023
Not supporting java.util.Date is very violent, and this solution of invading SQL is not good.
Later, I will output an abnormal time type, which I have encountered in production, and I am very upset.
@zhicwu
filimonov commentedon Feb 3, 2023
Workaround: Try to adjust the clickhouse setting
date_time_input_format=best effort (instead of basic which is default)
yanye666 commentedon Feb 3, 2023
lower version support. Do you need to adjust parameters for an advanced version? I don't think it's reasonable.
zhicwu commentedon Feb 3, 2023
That sounds really painful, any specific query you can share and I'll see if I can help.
@aadant, hahaha, very true. The problem is on ClickHouse side. Since it does not support prepared statement like other databases, the JDBC driver has to figure out column types by itself. It either trusts the intention(in this case, java.util.Date is more suitable for DateTime64, not DateTime32 or Date), or try to infer parameter type by parsing the query(when
inputfunction or a cleanvaluesexpression was used). Understood the query and parameters came from Kettle, but there's user defined Java/script step that you can leverage.@yanye666, calm down and don't be sad. Sorry I could not answer all questions in time, as I only work on this project in my spare time. As to the issue, as I explained in above, due to various limitation, you'd better take a workaround instead of counting on a feature being implemented soon.
Sure, feel free to share more cases and I'll try to help.
aadant commentedon Feb 3, 2023
thanks, looks like a reasonable workaround (will set it on the user profile that is hit by the issue)
yanye666 commentedon Feb 5, 2023
This is me testing the entry between two versions of different types.
clickhouse version :22.1.3.7
notice:
see test code !!!!
`package com.xk.order;import com.alibaba.druid.pool.DruidPooledConnection;
import com.clickhouse.jdbc.ClickHouseConnection;
import com.clickhouse.jdbc.ClickHouseStatement;
import com.xk.order.constants.Constant;
import org.junit.Assert;
import org.junit.Test;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
public class CkDateTimeTest extends SpringbootTestBase {
}`
yanye666 commentedon Feb 5, 2023
There were other issues after the upgrade
yanye666 commentedon Feb 6, 2023
in mybatis. mybatis has DateTypeHandler, which is implemented based on setTimeStamp, so java.util.Date is also supported in mybatis
According to the previous tests, mybatis should support insertion, but we have a special way to write it, as follows, which will cause an error.
zhicwu commentedon Feb 6, 2023
Thank you @yanye666 for summarizing issues you ran into and providing testing code. Apologize getting back a bit late as I'm still trying to fix an issue I encountered during benchmark over the weekend.
TabSeparatedtoRowBinary(not only for performance but also resolving serialization and deserialization issues along with better timezone support), and the latter does not support specifying null for a non-nullable column -null_as_defaultoption was added as a workaround for some but not all casesSince everyone else using mybatis will likely run into the same issues, are you willing to contribution a dialect or so to benefit more users?
yanye666 commentedon Feb 6, 2023
Thanks Your summary and answer,
My test is divided into two parts, the one above is jdbc mode, and the one below is mybatis mode.
on 0.3.1. Inserting clickhouse directly through mybatis has very low performance. So I used jdbc primordial(I don't know if there is any improvement after the upgrade.), which is why I am mainly testing jdbc mode.
Recently, I found your insert example.
insert example
It seems that using jdbc is not the best way. Do you have a test report? If not, I will try to test it later.
I don't think the performance of using mybatis insert in 0.3.2 has improved either.
2 remaining items
github-actions commentedon Jan 8, 2025
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!