-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dbeaver/dbeaver#23390 Support REAL_VECTOR type in HANA plugin #23391
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d0c624a
dbeaver/dbeaver#23390 Support REAL_VECTOR type in HANA plugin
stefanuhrig 190c4d3
Fix codacity issue
stefanuhrig 2222543
Move data type name to HANAConstants class
stefanuhrig 075685d
Introduce constants for datatype names
stefanuhrig 4c2b8de
Change data type constant name prefix
stefanuhrig a3bd2e7
Merge branch 'devel' into devel
Matvey16 aa2241c
Merge branch 'devel' into devel
Matvey16 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -24,4 +24,9 @@ public class HANAConstants { | |||||
|
||||||
// pseudo schema for PUBLIC SYNONYMs | ||||||
public static final String SCHEMA_PUBLIC = "PUBLIC"; | ||||||
|
||||||
// Data type names | ||||||
public static final String DATATYPENAME_REAL_VECTOR = "REAL_VECTOR"; | ||||||
public static final String DATATYPENAME_ST_GEOMETRY = "ST_GEOMETRY"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
public static final String DATATYPENAME_ST_POINT = "ST_POINT"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...ss.dbeaver.ext.hana/src/org/jkiss/dbeaver/ext/hana/model/data/HANAVectorValueHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* DBeaver - Universal Database Manager | ||
* Copyright (C) 2010-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jkiss.dbeaver.ext.hana.model.data; | ||
|
||
import java.sql.SQLException; | ||
import java.sql.Types; | ||
|
||
import org.jkiss.dbeaver.model.data.DBDCollection; | ||
import org.jkiss.dbeaver.model.exec.DBCException; | ||
import org.jkiss.dbeaver.model.exec.DBCLogicalOperator; | ||
import org.jkiss.dbeaver.model.exec.DBCSession; | ||
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; | ||
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession; | ||
import org.jkiss.dbeaver.model.impl.jdbc.data.JDBCCollection; | ||
import org.jkiss.dbeaver.model.impl.jdbc.data.handlers.JDBCArrayValueHandler; | ||
import org.jkiss.dbeaver.model.struct.DBSTypedObject; | ||
|
||
public class HANAVectorValueHandler extends JDBCArrayValueHandler { | ||
|
||
public static final HANAVectorValueHandler INSTANCE = new HANAVectorValueHandler(); | ||
|
||
private static DBCLogicalOperator[] SUPPORTED_OPERATORS = { DBCLogicalOperator.IS_NOT_NULL, | ||
DBCLogicalOperator.IS_NULL }; | ||
|
||
@Override | ||
protected boolean useGetArray(DBCSession session, DBSTypedObject type) { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected void bindParameter(JDBCSession session, JDBCPreparedStatement statement, DBSTypedObject paramType, | ||
int paramIndex, Object value) throws DBCException, SQLException { | ||
if (value == null) { | ||
statement.setNull(paramIndex, Types.ARRAY); | ||
} else if (value instanceof DBDCollection) { | ||
DBDCollection collection = (DBDCollection) value; | ||
if (collection.isNull()) { | ||
statement.setNull(paramIndex, Types.ARRAY); | ||
} else if (collection instanceof JDBCCollection) { | ||
JDBCCollection jc = (JDBCCollection) collection; | ||
if (jc.getComponentType().getTypeID() != Types.REAL) { | ||
throw new DBCException("Only REAL numbers are allowed in vectors"); | ||
} | ||
float[] nvals = new float[jc.size()]; | ||
for (int i = 0; i < nvals.length; ++i) { | ||
Float val = (Float) jc.get(i); | ||
if (val == null) { | ||
throw new DBCException("NULL elements are not allowed in vectors"); | ||
} | ||
nvals[i] = val; | ||
} | ||
statement.setObject(paramIndex, nvals); | ||
} else { | ||
throw new DBCException("Array parameter type '" + value.getClass().getName() + "' not supported"); | ||
} | ||
} else { | ||
throw new DBCException("Array parameter type '" + value.getClass().getName() + "' not supported"); | ||
} | ||
} | ||
|
||
@Override | ||
public DBCLogicalOperator[] getSupportedOperators(DBSTypedObject attribute) { | ||
return SUPPORTED_OPERATORS; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.