Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-28 Thread via GitHub


morningman merged PR #44160:
URL: https://github.com/apache/doris/pull/44160


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-26 Thread via GitHub


github-actions[bot] commented on PR #44160:
URL: https://github.com/apache/doris/pull/44160#issuecomment-2499940900

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-26 Thread via GitHub


github-actions[bot] commented on PR #44160:
URL: https://github.com/apache/doris/pull/44160#issuecomment-2499940820

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-26 Thread via GitHub


morningman closed pull request #44160: [Enhancement](jdbc catalog) Support 
reading some array types of PostgreSQL
URL: https://github.com/apache/doris/pull/44160


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-25 Thread via GitHub


zy-kkk commented on PR #44160:
URL: https://github.com/apache/doris/pull/44160#issuecomment-2499553317

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-25 Thread via GitHub


morningman commented on code in PR #44160:
URL: https://github.com/apache/doris/pull/44160#discussion_r1856802050


##
fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcPostgreSQLClient.java:
##
@@ -99,8 +151,43 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) 
{
 case "json":
 case "jsonb":
 return ScalarType.createStringType();
-default:
-return Type.UNSUPPORTED;
+default: {
+if (fieldSchema.getDataType() == Types.ARRAY && 
pgType.startsWith("_")) {
+return convertArrayType(fieldSchema);
+} else {
+return Type.UNSUPPORTED;
+}
+}
+}
+}
+
+private Type convertArrayType(JdbcFieldSchema fieldSchema) {
+int arrayDimensions = fieldSchema.getArrayDimensions().orElse(0);
+if (arrayDimensions == 0) {
+return Type.UNSUPPORTED;
+}
+
+String innerType = 
fieldSchema.getDataTypeName().orElse("unknown").substring(1);
+String[] supportedInnerType = new String[] {

Review Comment:
   Make it is static final field



##
fe/be-java-extensions/jdbc-scanner/src/main/java/org/apache/doris/jdbc/PostgreSQLJdbcExecutor.java:
##
@@ -122,4 +136,29 @@ private static String pgByteArrayToHexString(byte[] bytes) 
{
 }
 return hexString.toString();
 }
+
+private String handleNestedArray(Object array) {
+if (array == null) {
+return null;
+}
+StringBuilder sb = new StringBuilder();
+sb.append("[");
+int length = java.lang.reflect.Array.getLength(array);
+for (int i = 0; i < length; i++) {
+Object element = java.lang.reflect.Array.get(array, i);
+if (element != null && element.getClass().isArray()) {
+sb.append(handleNestedArray(element));
+} else if (element instanceof byte[]) {
+sb.append(pgByteArrayToHexString((byte[]) element));
+} else {
+String elementStr = element != null ? 
element.toString().trim() : "null";

Review Comment:
   Why use `trim()`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-22 Thread via GitHub


zy-kkk commented on PR #44160:
URL: https://github.com/apache/doris/pull/44160#issuecomment-2493239286

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] [Enhancement](jdbc catalog) Support reading some array types of PostgreSQL [doris]

2024-11-17 Thread via GitHub


doris-robot commented on PR #44160:
URL: https://github.com/apache/doris/pull/44160#issuecomment-2482139096

   
   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your 
PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
   
   Please clearly describe your PR:
   1. What problem was fixed (it's best to include specific error reporting 
information). How it was fixed.
   2. Which behaviors were modified. What was the previous behavior, what is it 
now, why was it modified, and what possible impacts might there be.
   3. What features were added. Why was this function added?
   4. Which code was refactored and why was this part of the code refactored?
   5. Which functions were optimized and what is the difference before and 
after the optimization?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]