String condition = filter.getCondition();
boolean isValidCondition = StringUtil.isNotEmptyOrSpaces(condition);
selectStatement.append(isValidCondition ? condition : COMMENT);
PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(project);
SQLFile selectStatementFile = (SQLFile)
psiFileFactory.createFileFromText(
"filter.sql",
dataset.getLanguageDialect(SQLLanguage.INSTANCE),
selectStatement.toString());
selectStatementFile.setParseRootId("subquery");
selectStatementFile.setActiveConnection(dataset.getConnectionHandler());
selectStatementFile.setCurrentSchema(dataset.getSchema());
document = DocumentUtil.getDocument(selectStatementFile);
document.createGuardedBlock(0, conditionStartOffset);
editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project);