### Question:
PostgresUniqueIndex extends Index<Long> { String createSelectStatement(Map<String, Object> keyValues) { return "SELECT id FROM " + fullCollectionName + " WHERE " + keyValues.entrySet().stream() .map(entry -> { String dataKey = PostgresqlUtils.toDataKey(entry.getKey()); if (!isSparse() && entry.getValue() == null) { return dataKey + " IS NULL"; } else if (entry.getValue() instanceof Number) { return "CASE json_typeof(" + dataKey.replace("->>", "->") + ")" + " WHEN 'number' THEN (" + dataKey + ")::numeric = ?::numeric" + " ELSE FALSE" + " END"; } else { return dataKey + " = ?"; } }) .collect(Collectors.joining(" AND ")); } PostgresUniqueIndex(PostgresqlBackend backend, String databaseName, String collectionName, String indexName,
                               List<IndexKey> keys, boolean sparse); void initialize(); @Override void drop(); @Override void checkAdd(Document document, MongoCollection<Long> collection); @Override void add(Document document, Long position, MongoCollection<Long> collection); @Override Long remove(Document document); @Override boolean canHandle(Document query); @Override Iterable<Long> getPositions(Document query); @Override long getCount(); @Override boolean isEmpty(); @Override long getDataSize(); @Override void checkUpdate(Document oldDocument, Document newDocument, MongoCollection<Long> collection); @Override void updateInPlace(Document oldDocument, Document newDocument, Long position, MongoCollection<Long> collection); @Override Long getPosition(Document document);  }### Answer:
@Test void testCreateSelectStatement() throws Exception { List<IndexKey> keys = new ArrayList<>(); keys.add(new IndexKey("a", true)); keys.add(new IndexKey("b", true)); PostgresUniqueIndex postgresUniqueIndex = new PostgresUniqueIndex(null, "db", "coll", "idx1", keys, false); Map<String, Object> keyValues = new LinkedHashMap<>(); keyValues.put("a", "some-value"); keyValues.put("b", null); String selectStatement = postgresUniqueIndex.createSelectStatement(keyValues); assertThat(selectStatement).isEqualTo("SELECT id FROM \"db\".\"coll\" WHERE data ->> 'a' = ? AND data ->> 'b' IS NULL"); }