Closed nbozic-zz closed 7 years ago
I've looked at issue and with current pointcut was able to reconstruct SelectStatement. But I'm thinking about another, more convenient pointcut for this purpose. Your ideas?
@f1yegor Could you please elaborate? I'm not sure I understand. The issue here is that when we create query object in connector we set empty string to statement instead of the statement itself. We didn't have time to add this but any help is appreciated.
Something like `
private final CQLStatement statement;
QueryBuilder(CQLStatement statement) {
this.statement = statement;
}
String build() {
if (statement instanceof SelectStatement) {
SelectStatement select = (SelectStatement) statement;
Selection selection = select.getSelection();
String columnsQuery = "";
if (selection != null) {
List<ColumnDefinition> columns = select.getSelection().getColumns();
List<String> columnNames = new ArrayList<>(columns.size());
for (ColumnDefinition column : columns) {
columnNames.add(column.name.toCQLString());
}
columnsQuery = StringUtils.join(columnNames, ", ");
}
return "SELECT " + columnsQuery + " FROM " + select.keyspace() + "." + select.columnFamily();
}
return "";
}
` and then use as statement query.
This looks like an extra effort just to get the statement which we already have at process method in QueryProcessor and there would need to be a significant effort to implement full select or upsert statements because of all the parameters. For example your code is missing WHERE params which are useful when investigating slow queries. I think @nivancevic did an investigation and we should be able to use the queryString parameter from process method and provide it to the wrapper using bytebuddy. @nivancevic Any comments on this?
Yes, I missed WHERE for further implementation.
Looked at implementation of ByteBuddy. It would be challenging or impossible, especially because processStatement
called from several places. Would be interesting to look at good solution.
When slow query is logged only statement type is extracted and in influx we see empty string for statement.