diff --git "a/test.json" "b/test.json"
new file mode 100644--- /dev/null
+++ "b/test.json"
@@ -0,0 +1,2002 @@
+[
+ {
+ "comment": "```suggestion assertThat(k2).hasSameHashCodeAs(k1); ```",
+ "method_body": "private void testSerialization(BlobKey.BlobType blobType) throws Exception {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = CommonTestUtils.createCopySerializable(k1);\nassertThat(k2).isEqualTo(k1);\nassertThat(k2.hashCode()).isEqualTo(k1.hashCode());\nassertThat(k1.compareTo(k2)).isZero();\n}",
+ "target_code": "assertThat(k2.hashCode()).isEqualTo(k1.hashCode());",
+ "method_body_after": "private void testSerialization(BlobKey.BlobType blobType) throws Exception {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = CommonTestUtils.createCopySerializable(k1);\nassertThat(k2).isEqualTo(k1);\nassertThat(k2).hasSameHashCodeAs(k1);\nassertThat(k1).isEqualByComparingTo(k2);\n}",
+ "context_before": "class BlobKeyTest {\n/** The first key array to be used during the unit tests. */\nprivate static final byte[] KEY_ARRAY_1 = new byte[BlobKey.SIZE];\n/** The second key array to be used during the unit tests. */\nprivate static final byte[] KEY_ARRAY_2 = new byte[BlobKey.SIZE];\n/** First byte array to use for the random component of a {@link BlobKey}. */\nprivate static final byte[] RANDOM_ARRAY_1 = new byte[AbstractID.SIZE];\n/** Second byte array to use for the random component of a {@link BlobKey}. */\nprivate static final byte[] RANDOM_ARRAY_2 = new byte[AbstractID.SIZE];\n/*\n* Initialize the key and random arrays.\n*/\nstatic {\nfor (int i = 0; i < KEY_ARRAY_1.length; ++i) {\nKEY_ARRAY_1[i] = (byte) i;\nKEY_ARRAY_2[i] = (byte) (i + 1);\n}\nfor (int i = 0; i < RANDOM_ARRAY_1.length; ++i) {\nRANDOM_ARRAY_1[i] = (byte) i;\nRANDOM_ARRAY_2[i] = (byte) (i + 1);\n}\n}\n@Test\nvoid testCreateKey() {\nBlobKey key = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1);\nverifyType(PERMANENT_BLOB, key);\nassertThat(key.getHash()).isEqualTo(KEY_ARRAY_1);\nkey = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1);\nverifyType(TRANSIENT_BLOB, key);\nassertThat(key.getHash()).isEqualTo(KEY_ARRAY_1);\n}\n@Test\nvoid testSerializationTransient() throws Exception {\ntestSerialization(TRANSIENT_BLOB);\n}\n@Test\nvoid testSerializationPermanent() throws Exception {\ntestSerialization(PERMANENT_BLOB);\n}\n/** Tests the serialization/deserialization of BLOB keys. */\n@Test\nvoid testEqualsTransient() {\ntestEquals(TRANSIENT_BLOB);\n}\n@Test\nvoid testEqualsPermanent() {\ntestEquals(PERMANENT_BLOB);\n}\n/** Tests the {@link BlobKey\nprivate void testEquals(BlobKey.BlobType blobType) {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k3 = BlobKey.createKey(blobType, KEY_ARRAY_2, RANDOM_ARRAY_1);\nfinal BlobKey k4 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_2);\nassertThat(k1.equals(k2)).isTrue();\nassertThat(k2.equals(k1)).isTrue();\nassertThat(k2.hashCode()).isEqualTo(k1.hashCode());\nassertThat(k1.equals(k3)).isFalse();\nassertThat(k3.equals(k1)).isFalse();\nassertThat(k1.equals(k4)).isFalse();\nassertThat(k4.equals(k1)).isFalse();\nassertThat(k1.equals(null)).isFalse();\nassertThat(k1.equals(this)).isFalse();\n}\n/** Tests the equals method. */\n@Test\nvoid testEqualsDifferentBlobType() {\nfinal BlobKey k1 = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nassertThat(k1.equals(k2)).isFalse();\nassertThat(k2.equals(k1)).isFalse();\n}\n@Test\nvoid testComparesTransient() {\ntestCompares(TRANSIENT_BLOB);\n}\n@Test\nvoid testComparesPermanent() {\ntestCompares(PERMANENT_BLOB);\n}\n/** Tests the compares method. */\nprivate void testCompares(BlobKey.BlobType blobType) {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k3 = BlobKey.createKey(blobType, KEY_ARRAY_2, RANDOM_ARRAY_1);\nfinal BlobKey k4 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_2);\nassertThat(k1.compareTo(k2)).isZero();\nassertThat(k2.compareTo(k1)).isZero();\nassertThat(k1.compareTo(k3)).isLessThan(0);\nassertThat(k1.compareTo(k4)).isLessThan(0);\nassertThat(k3.compareTo(k1)).isGreaterThan(0);\nassertThat(k4.compareTo(k1)).isGreaterThan(0);\n}\n@Test\nvoid testComparesDifferentBlobType() {\nfinal BlobKey k1 = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nassertThat(k1.compareTo(k2)).isGreaterThan(0);\nassertThat(k2.compareTo(k1)).isLessThan(0);\n}\n@Test\nvoid testStreamsTransient() throws Exception {\ntestStreams(TRANSIENT_BLOB);\n}\n@Test\nvoid testStreamsPermanent() throws Exception {\ntestStreams(PERMANENT_BLOB);\n}\n@Test\nvoid testToFromStringPermanentKey() {\ntestToFromString(BlobKey.createKey(PERMANENT_BLOB));\n}\n@Test\nvoid testToFromStringTransientKey() {\ntestToFromString(BlobKey.createKey(TRANSIENT_BLOB));\n}\nprivate void testToFromString(BlobKey blobKey) {\nfinal String stringRepresentation = blobKey.toString();\nfinal BlobKey parsedBlobKey = BlobKey.fromString(stringRepresentation);\nassertThat(blobKey).isEqualTo(parsedBlobKey);\n}\n@Test\nvoid testFromStringFailsWithWrongInput() {\nassertThatThrownBy(() -> BlobKey.fromString(\"foobar\"))\n.isInstanceOf(IllegalStateException.class);\n}\n@Test\nvoid testFromStringFailsWithInvalidBlobKeyType() {\nassertThatThrownBy(\n() ->\nBlobKey.fromString(\nString.format(\n\"x-%s-%s\",\nStringUtils.byteToHexString(KEY_ARRAY_1),\nStringUtils.byteToHexString(RANDOM_ARRAY_1))))\n.isInstanceOf(IllegalStateException.class);\n}\n/** Test the serialization/deserialization using input/output streams. */\nprivate void testStreams(BlobKey.BlobType blobType) throws IOException {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal ByteArrayOutputStream baos = new ByteArrayOutputStream(20);\nk1.writeToOutputStream(baos);\nbaos.close();\nfinal ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());\nfinal BlobKey k2 = BlobKey.readFromInputStream(bais);\nassertThat(k2).isEqualTo(k1);\n}\n/**\n* Verifies that the two given key's are different in total but share the same hash.\n*\n* @param key1 first blob key\n* @param key2 second blob key\n*/\nstatic void verifyKeyDifferentHashEquals(BlobKey key1, BlobKey key2) {\nassertThat(key1).isNotEqualTo(key2);\nassertThat(key1.getHash()).isEqualTo(key2.getHash());\n}\n/**\n* Verifies that the two given key's are different in total and also have different hashes.\n*\n* @param key1 first blob key\n* @param key2 second blob key\n*/\nstatic void verifyKeyDifferentHashDifferent(BlobKey key1, BlobKey key2) {\nassertThat(key1).isNotEqualTo(key2);\nassertThat(key1.getHash()).isNotEqualTo(key2.getHash());\n}\n/**\n* Verifies that the given key is of an expected type.\n*\n* @param expected the type the key should have\n* @param key the key to verify\n*/\nstatic void verifyType(BlobKey.BlobType expected, BlobKey key) {\nif (expected == PERMANENT_BLOB) {\nassertThat(key).isInstanceOf(PermanentBlobKey.class);\n} else {\nassertThat(key).isInstanceOf(TransientBlobKey.class);\n}\n}\n}",
+ "context_after": "class BlobKeyTest {\n/** The first key array to be used during the unit tests. */\nprivate static final byte[] KEY_ARRAY_1 = new byte[BlobKey.SIZE];\n/** The second key array to be used during the unit tests. */\nprivate static final byte[] KEY_ARRAY_2 = new byte[BlobKey.SIZE];\n/** First byte array to use for the random component of a {@link BlobKey}. */\nprivate static final byte[] RANDOM_ARRAY_1 = new byte[AbstractID.SIZE];\n/** Second byte array to use for the random component of a {@link BlobKey}. */\nprivate static final byte[] RANDOM_ARRAY_2 = new byte[AbstractID.SIZE];\n/*\n* Initialize the key and random arrays.\n*/\nstatic {\nfor (int i = 0; i < KEY_ARRAY_1.length; ++i) {\nKEY_ARRAY_1[i] = (byte) i;\nKEY_ARRAY_2[i] = (byte) (i + 1);\n}\nfor (int i = 0; i < RANDOM_ARRAY_1.length; ++i) {\nRANDOM_ARRAY_1[i] = (byte) i;\nRANDOM_ARRAY_2[i] = (byte) (i + 1);\n}\n}\n@Test\nvoid testCreateKey() {\nBlobKey key = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1);\nverifyType(PERMANENT_BLOB, key);\nassertThat(key.getHash()).isEqualTo(KEY_ARRAY_1);\nkey = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1);\nverifyType(TRANSIENT_BLOB, key);\nassertThat(key.getHash()).isEqualTo(KEY_ARRAY_1);\n}\n@Test\nvoid testSerializationTransient() throws Exception {\ntestSerialization(TRANSIENT_BLOB);\n}\n@Test\nvoid testSerializationPermanent() throws Exception {\ntestSerialization(PERMANENT_BLOB);\n}\n/** Tests the serialization/deserialization of BLOB keys. */\n@Test\nvoid testEqualsTransient() {\ntestEquals(TRANSIENT_BLOB);\n}\n@Test\nvoid testEqualsPermanent() {\ntestEquals(PERMANENT_BLOB);\n}\n/** Tests the {@link BlobKey\nprivate void testEquals(BlobKey.BlobType blobType) {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k3 = BlobKey.createKey(blobType, KEY_ARRAY_2, RANDOM_ARRAY_1);\nfinal BlobKey k4 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_2);\nassertThat(k1).isEqualTo(k2);\nassertThat(k2).isEqualTo(k1);\nassertThat(k2).hasSameHashCodeAs(k1);\nassertThat(k1).isNotEqualTo(k3);\nassertThat(k3).isNotEqualTo(k1);\nassertThat(k1).isNotEqualTo(k4);\nassertThat(k4).isNotEqualTo(k1);\nassertThat(k1).isNotEqualTo(null);\nassertThat(k1).isNotEqualTo(this);\n}\n/** Tests the equals method. */\n@Test\nvoid testEqualsDifferentBlobType() {\nfinal BlobKey k1 = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nassertThat(k1).isNotEqualTo(k2);\nassertThat(k2).isNotEqualTo(k1);\n}\n@Test\nvoid testComparesTransient() {\ntestCompares(TRANSIENT_BLOB);\n}\n@Test\nvoid testComparesPermanent() {\ntestCompares(PERMANENT_BLOB);\n}\n/** Tests the compares method. */\nprivate void testCompares(BlobKey.BlobType blobType) {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k3 = BlobKey.createKey(blobType, KEY_ARRAY_2, RANDOM_ARRAY_1);\nfinal BlobKey k4 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_2);\nassertThat(k1).isEqualByComparingTo(k2);\nassertThat(k2).isEqualByComparingTo(k1);\nassertThat(k1).isLessThan(k3);\nassertThat(k1).isLessThan(k4);\nassertThat(k3).isGreaterThan(k1);\nassertThat(k4).isGreaterThan(k1);\n}\n@Test\nvoid testComparesDifferentBlobType() {\nfinal BlobKey k1 = BlobKey.createKey(TRANSIENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal BlobKey k2 = BlobKey.createKey(PERMANENT_BLOB, KEY_ARRAY_1, RANDOM_ARRAY_1);\nassertThat(k1).isGreaterThan(k2);\nassertThat(k2).isLessThan(k1);\n}\n@Test\nvoid testStreamsTransient() throws Exception {\ntestStreams(TRANSIENT_BLOB);\n}\n@Test\nvoid testStreamsPermanent() throws Exception {\ntestStreams(PERMANENT_BLOB);\n}\n@Test\nvoid testToFromStringPermanentKey() {\ntestToFromString(BlobKey.createKey(PERMANENT_BLOB));\n}\n@Test\nvoid testToFromStringTransientKey() {\ntestToFromString(BlobKey.createKey(TRANSIENT_BLOB));\n}\nprivate void testToFromString(BlobKey blobKey) {\nfinal String stringRepresentation = blobKey.toString();\nfinal BlobKey parsedBlobKey = BlobKey.fromString(stringRepresentation);\nassertThat(blobKey).isEqualTo(parsedBlobKey);\n}\n@Test\nvoid testFromStringFailsWithWrongInput() {\nassertThatThrownBy(() -> BlobKey.fromString(\"foobar\"))\n.isInstanceOf(IllegalStateException.class);\n}\n@Test\nvoid testFromStringFailsWithInvalidBlobKeyType() {\nassertThatThrownBy(\n() ->\nBlobKey.fromString(\nString.format(\n\"x-%s-%s\",\nStringUtils.byteToHexString(KEY_ARRAY_1),\nStringUtils.byteToHexString(RANDOM_ARRAY_1))))\n.isInstanceOf(IllegalStateException.class);\n}\n/** Test the serialization/deserialization using input/output streams. */\nprivate void testStreams(BlobKey.BlobType blobType) throws IOException {\nfinal BlobKey k1 = BlobKey.createKey(blobType, KEY_ARRAY_1, RANDOM_ARRAY_1);\nfinal ByteArrayOutputStream baos = new ByteArrayOutputStream(20);\nk1.writeToOutputStream(baos);\nbaos.close();\nfinal ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());\nfinal BlobKey k2 = BlobKey.readFromInputStream(bais);\nassertThat(k2).isEqualTo(k1);\n}\n/**\n* Verifies that the two given key's are different in total but share the same hash.\n*\n* @param key1 first blob key\n* @param key2 second blob key\n*/\nstatic void verifyKeyDifferentHashEquals(BlobKey key1, BlobKey key2) {\nassertThat(key1).isNotEqualTo(key2);\nassertThat(key1.getHash()).isEqualTo(key2.getHash());\n}\n/**\n* Verifies that the two given key's are different in total and also have different hashes.\n*\n* @param key1 first blob key\n* @param key2 second blob key\n*/\nstatic void verifyKeyDifferentHashDifferent(BlobKey key1, BlobKey key2) {\nassertThat(key1).isNotEqualTo(key2);\nassertThat(key1.getHash()).isNotEqualTo(key2.getHash());\n}\n/**\n* Verifies that the given key is of an expected type.\n*\n* @param expected the type the key should have\n* @param key the key to verify\n*/\nstatic void verifyType(BlobKey.BlobType expected, BlobKey key) {\nif (expected == PERMANENT_BLOB) {\nassertThat(key).isInstanceOf(PermanentBlobKey.class);\n} else {\nassertThat(key).isInstanceOf(TransientBlobKey.class);\n}\n}\n}"
+ },
+ {
+ "comment": "shall this protected by lock? otherwise during the removal, someone set the to-be-removed-volume as default or bind it to db/table?",
+ "method_body": "public void removeStorageVolume(String name) throws AnalysisException, DdlException {\nStorageVolume sv = getStorageVolumeByName(name);\nPreconditions.checkState(sv != null,\n\"Storage volume '%s' does not exist\", name);\nPreconditions.checkState(defaultStorageVolumeId != sv.getId(),\n\"default storage volume can not be removed\");\nPreconditions.checkState(!storageVolumeToDbs.containsKey(sv.getId())\n&& !storageVolumeToTables.containsKey(sv.getId()),\n\"Storage volume '%s' is referenced by db or table\", name);\nGlobalStateMgr.getCurrentState().getStarOSAgent().removeFileStoreByName(name);\n}",
+ "target_code": "Preconditions.checkState(sv != null,",
+ "method_body_after": "public void removeStorageVolume(String name) throws AnalysisException, DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.writeLock())) {\nStorageVolume sv = getStorageVolumeByName(name);\nPreconditions.checkState(sv != null,\n\"Storage volume '%s' does not exist\", name);\nPreconditions.checkState(defaultStorageVolumeId != sv.getId(),\n\"default storage volume can not be removed\");\nSet dbs = storageVolumeToDbs.get(sv.getId());\nSet tables = storageVolumeToTables.get(sv.getId());\nPreconditions.checkState(dbs == null && tables == null,\n\"Storage volume '%s' is referenced by dbs or tables, dbs: %s, tables: %s\",\nname, dbs != null ? dbs.toString() : \"[]\", tables != null ? tables.toString() : \"[]\");\nGlobalStateMgr.getCurrentState().getStarOSAgent().removeFileStoreByName(name);\n}\n}",
+ "context_before": "class SharedDataStorageVolumeMgr extends StorageVolumeMgr {\n@Override\npublic Long createStorageVolume(String name, String svType, List locations, Map params,\nOptional enabled, String comment)\nthrows AlreadyExistsException, AnalysisException, DdlException {\nif (exists(name)) {\nthrow new AlreadyExistsException(String.format(\"Storage volume '%s' already exists\", name));\n}\nStorageVolume sv = new StorageVolume(0, name, svType, locations, params, enabled.orElse(true), comment);\nreturn Long.valueOf(GlobalStateMgr.getCurrentState().getStarOSAgent().addFileStore(sv.toFileStoreInfo()));\n}\n@Override\n@Override\npublic void updateStorageVolume(String name, Map params,\nOptional enabled, String comment) throws DdlException, AnalysisException {\nStorageVolume sv = getStorageVolumeByName(name);\nPreconditions.checkState(sv != null, \"Storage volume '%s' does not exist\", name);\nif (enabled.isPresent()) {\nboolean enabledValue = enabled.get();\nif (!enabledValue) {\nPreconditions.checkState(sv.getId() != defaultStorageVolumeId, \"Default volume can not be disabled\");\n}\nsv.setEnabled(enabledValue);\n}\nif (!comment.isEmpty()) {\nsv.setComment(comment);\n}\nif (!params.isEmpty()) {\nsv.setCloudConfiguration(params);\n}\nGlobalStateMgr.getCurrentState().getStarOSAgent().updateFileStore(sv.toFileStoreInfo());\n}\n@Override\npublic void setDefaultStorageVolume(String svKey) throws AnalysisException, DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.writeLock())) {\nStorageVolume sv = getStorageVolumeByName(svKey);\nPreconditions.checkState(sv != null, \"Storage volume '%s' does not exist\", svKey);\nPreconditions.checkState(sv.getEnabled(), \"Storage volume '%s' is disabled\", svKey);\nthis.defaultStorageVolumeId = sv.getId();\n}\n}\n@Override\npublic boolean exists(String svKey) throws DdlException {\ntry {\nStorageVolume sv = getStorageVolumeByName(svKey);\nreturn sv != null;\n} catch (AnalysisException e) {\nthrow new DdlException(e.getMessage());\n}\n}\n@Override\npublic StorageVolume getStorageVolumeByName(String svKey) throws AnalysisException {\ntry {\nFileStoreInfo fileStoreInfo = GlobalStateMgr.getCurrentState().getStarOSAgent().getFileStoreByName(svKey);\nif (fileStoreInfo == null) {\nreturn null;\n}\nreturn StorageVolume.fromFileStoreInfo(fileStoreInfo);\n} catch (DdlException e) {\nthrow new AnalysisException(e.getMessage());\n}\n}\n@Override\npublic StorageVolume getStorageVolume(long storageVolumeId) throws AnalysisException {\nreturn null;\n}\n@Override\npublic List listStorageVolumeNames() throws DdlException {\nreturn GlobalStateMgr.getCurrentState().getStarOSAgent().listFileStore()\n.stream().map(FileStoreInfo::getFsName).collect(Collectors.toList());\n}\n}",
+ "context_after": "class SharedDataStorageVolumeMgr extends StorageVolumeMgr {\n@Override\npublic Long createStorageVolume(String name, String svType, List locations, Map params,\nOptional enabled, String comment)\nthrows AlreadyExistsException, AnalysisException, DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.writeLock())) {\nif (exists(name)) {\nthrow new AlreadyExistsException(String.format(\"Storage volume '%s' already exists\", name));\n}\nStorageVolume sv = new StorageVolume(0, name, svType, locations, params, enabled.orElse(true), comment);\nreturn Long.valueOf(GlobalStateMgr.getCurrentState().getStarOSAgent().addFileStore(sv.toFileStoreInfo()));\n}\n}\n@Override\n@Override\npublic void updateStorageVolume(String name, Map params,\nOptional enabled, String comment) throws DdlException, AnalysisException {\ntry (LockCloseable lock = new LockCloseable(rwLock.writeLock())) {\nStorageVolume sv = getStorageVolumeByName(name);\nPreconditions.checkState(sv != null, \"Storage volume '%s' does not exist\", name);\nif (enabled.isPresent()) {\nboolean enabledValue = enabled.get();\nif (!enabledValue) {\nPreconditions.checkState(sv.getId() != defaultStorageVolumeId, \"Default volume can not be disabled\");\n}\nsv.setEnabled(enabledValue);\n}\nif (!comment.isEmpty()) {\nsv.setComment(comment);\n}\nif (!params.isEmpty()) {\nsv.setCloudConfiguration(params);\n}\nGlobalStateMgr.getCurrentState().getStarOSAgent().updateFileStore(sv.toFileStoreInfo());\n}\n}\n@Override\npublic void setDefaultStorageVolume(String svKey) throws AnalysisException, DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.writeLock())) {\nStorageVolume sv = getStorageVolumeByName(svKey);\nPreconditions.checkState(sv != null, \"Storage volume '%s' does not exist\", svKey);\nPreconditions.checkState(sv.getEnabled(), \"Storage volume '%s' is disabled\", svKey);\nthis.defaultStorageVolumeId = sv.getId();\n}\n}\n@Override\npublic boolean exists(String svKey) throws DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.readLock())) {\ntry {\nStorageVolume sv = getStorageVolumeByName(svKey);\nreturn sv != null;\n} catch (AnalysisException e) {\nthrow new DdlException(e.getMessage());\n}\n}\n}\n@Override\npublic StorageVolume getStorageVolumeByName(String svKey) throws AnalysisException {\ntry (LockCloseable lock = new LockCloseable(rwLock.readLock())) {\ntry {\nFileStoreInfo fileStoreInfo = GlobalStateMgr.getCurrentState().getStarOSAgent().getFileStoreByName(svKey);\nif (fileStoreInfo == null) {\nreturn null;\n}\nreturn StorageVolume.fromFileStoreInfo(fileStoreInfo);\n} catch (DdlException e) {\nthrow new AnalysisException(e.getMessage());\n}\n}\n}\n@Override\npublic StorageVolume getStorageVolume(long storageVolumeId) throws AnalysisException {\nreturn null;\n}\n@Override\npublic List listStorageVolumeNames() throws DdlException {\ntry (LockCloseable lock = new LockCloseable(rwLock.readLock())) {\nreturn GlobalStateMgr.getCurrentState().getStarOSAgent().listFileStore()\n.stream().map(FileStoreInfo::getFsName).collect(Collectors.toList());\n}\n}\n}"
+ },
+ {
+ "comment": "So you prefer `config.set(CoreOptions.DEFAULT_PARALLELISM, 1);` to `env.setParallelism(1)`? \ud83d\ude05",
+ "method_body": "private StreamExecutionEnvironment getExecutionEnvironment() {\nConfiguration config = new Configuration();\nconfig.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.BATCH);\nconfig.set(CoreOptions.DEFAULT_PARALLELISM, 1);\nconfig.set(ExecutionCheckpointingOptions.CHECKPOINTING_INTERVAL, Duration.ofMillis(42));\nfinal StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(\nconfig);\nenv.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, Time.milliseconds(1)));\nreturn env;\n}",
+ "target_code": "config.set(CoreOptions.DEFAULT_PARALLELISM, 1);",
+ "method_body_after": "private StreamExecutionEnvironment getExecutionEnvironment() {\nConfiguration config = new Configuration();\nconfig.set(ExecutionOptions.RUNTIME_MODE, RuntimeExecutionMode.BATCH);\nfinal StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(\nconfig);\nenv.setParallelism(1);\nenv.enableCheckpointing(42);\nenv.setRestartStrategy(RestartStrategies.fixedDelayRestart(10, Time.milliseconds(1)));\nreturn env;\n}",
+ "context_before": "class DataStreamBatchExecutionITCase {\nprivate static final int DEFAULT_PARALLELISM = 1;\n@ClassRule\npublic static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource(\nnew MiniClusterResourceConfiguration.Builder()\n.setNumberTaskManagers(1)\n.setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM)\n.build());\n/**\n* We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline\n* before the key-by should not be re-executed. Only the part after that will restart. We check\n* that by suffixing the attempt number to records and asserting the correct number.\n*/\n@Test\npublic void batchFailoverWithKeyByBarrier() throws Exception {\nfinal StreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource source = env.fromElements(\"foo\", \"bar\");\nSingleOutputStreamOperator mapped = source\n.map(new SuffixAttemptId(\"a\"))\n.map(new SuffixAttemptId(\"b\"))\n.keyBy(in -> in)\n.map(new SuffixAttemptId(\"c\"))\n.map(new OnceFailingMapper(\"d\"));\ntry (CloseableIterator result = mapped.executeAndCollect()) {\nassertThat(\niteratorToList(result),\ncontainsInAnyOrder(\"foo-a0-b0-c1-d1\", \"bar-a0-b0-c1-d1\"));\n}\n}\n@Test\npublic void batchReduceSingleResultPerKey() throws Exception {\nStreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource numbers = env\n.fromSequence(0, 10);\nKeyedStream stream = numbers.keyBy(i -> i % 2);\nDataStream sums = stream.reduce(Long::sum);\ntry (CloseableIterator sumsIterator = sums.executeAndCollect()) {\nList results = CollectionUtil.iteratorToList(sumsIterator);\nassertThat(results, equalTo(Arrays.asList(\n30L, 25L\n)));\n}\n}\n@Test\npublic void batchSumSingleResultPerKey() throws Exception {\nStreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource numbers = env\n.fromSequence(0, 10);\nKeyedStream stream = numbers.keyBy(i -> i % 2);\nDataStream sums = stream.sum(0);\ntry (CloseableIterator sumsIterator = sums.executeAndCollect()) {\nList results = CollectionUtil.iteratorToList(sumsIterator);\nassertThat(results, equalTo(Arrays.asList(\n30L, 25L\n)));\n}\n}\n/** Adds the attempt number as a suffix. */\npublic static class SuffixAttemptId extends RichMapFunction {\nprivate final String suffix;\npublic SuffixAttemptId(String suffix) {\nthis.suffix = suffix;\n}\n@Override\npublic String map(String value) {\nreturn value + \"-\" + suffix + getRuntimeContext().getAttemptNumber();\n}\n}\n/**\n* Adds the attempt number as a suffix.\n*\n*
Also fails by throwing an exception on the first attempt.\n*/\npublic static class OnceFailingMapper extends RichMapFunction {\nprivate final String suffix;\npublic OnceFailingMapper(String suffix) {\nthis.suffix = suffix;\n}\n@Override\npublic String map(String value) throws Exception {\nif (getRuntimeContext().getAttemptNumber() <= 0) {\nthrow new RuntimeException(\"FAILING\");\n}\nreturn value + \"-\" + suffix + getRuntimeContext().getAttemptNumber();\n}\n}\n}",
+ "context_after": "class DataStreamBatchExecutionITCase {\nprivate static final int DEFAULT_PARALLELISM = 1;\n@ClassRule\npublic static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource(\nnew MiniClusterResourceConfiguration.Builder()\n.setNumberTaskManagers(1)\n.setNumberSlotsPerTaskManager(DEFAULT_PARALLELISM)\n.build());\n/**\n* We induce a failure in the last mapper. In BATCH execution mode the part of the pipeline\n* before the key-by should not be re-executed. Only the part after that will restart. We check\n* that by suffixing the attempt number to records and asserting the correct number.\n*/\n@Test\npublic void batchFailoverWithKeyByBarrier() throws Exception {\nfinal StreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource source = env.fromElements(\"foo\", \"bar\");\nSingleOutputStreamOperator mapped = source\n.map(new SuffixAttemptId(\"a\"))\n.map(new SuffixAttemptId(\"b\"))\n.keyBy(in -> in)\n.map(new SuffixAttemptId(\"c\"))\n.map(new OnceFailingMapper(\"d\"));\ntry (CloseableIterator result = mapped.executeAndCollect()) {\nassertThat(\niteratorToList(result),\ncontainsInAnyOrder(\"foo-a0-b0-c1-d1\", \"bar-a0-b0-c1-d1\"));\n}\n}\n@Test\npublic void batchReduceSingleResultPerKey() throws Exception {\nStreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource numbers = env\n.fromSequence(0, 10);\nKeyedStream stream = numbers.keyBy(i -> i % 2);\nDataStream sums = stream.reduce(Long::sum);\ntry (CloseableIterator sumsIterator = sums.executeAndCollect()) {\nList results = CollectionUtil.iteratorToList(sumsIterator);\nassertThat(results, equalTo(Arrays.asList(\n30L, 25L\n)));\n}\n}\n@Test\npublic void batchSumSingleResultPerKey() throws Exception {\nStreamExecutionEnvironment env = getExecutionEnvironment();\nDataStreamSource numbers = env\n.fromSequence(0, 10);\nKeyedStream stream = numbers.keyBy(i -> i % 2);\nDataStream sums = stream.sum(0);\ntry (CloseableIterator sumsIterator = sums.executeAndCollect()) {\nList results = CollectionUtil.iteratorToList(sumsIterator);\nassertThat(results, equalTo(Arrays.asList(\n30L, 25L\n)));\n}\n}\n/** Adds the attempt number as a suffix. */\npublic static class SuffixAttemptId extends RichMapFunction {\nprivate final String suffix;\npublic SuffixAttemptId(String suffix) {\nthis.suffix = suffix;\n}\n@Override\npublic String map(String value) {\nreturn value + \"-\" + suffix + getRuntimeContext().getAttemptNumber();\n}\n}\n/**\n* Adds the attempt number as a suffix.\n*\n*
Also fails by throwing an exception on the first attempt.\n*/\npublic static class OnceFailingMapper extends RichMapFunction {\nprivate final String suffix;\npublic OnceFailingMapper(String suffix) {\nthis.suffix = suffix;\n}\n@Override\npublic String map(String value) throws Exception {\nif (getRuntimeContext().getAttemptNumber() <= 0) {\nthrow new RuntimeException(\"FAILING\");\n}\nreturn value + \"-\" + suffix + getRuntimeContext().getAttemptNumber();\n}\n}\n}"
+ },
+ {
+ "comment": "nit: inconsistent `final`. I don't see you re-setting this variable.",
+ "method_body": "private void checkNamingPattern(DetailAST blockCommentToken) {\nif (!BlockCommentPosition.isOnMethod(blockCommentToken)) {\nreturn;\n}\nDetailNode javadocNode = null;\ntry {\njavadocNode = DetailNodeTreeStringPrinter.parseJavadocAsDetailNode(blockCommentToken);\n} catch (IllegalArgumentException ex) {\n}\nif (javadocNode == null) {\nreturn;\n}\nfor (DetailNode node : javadocNode.getChildren()) {\nif (node.getType() != JavadocTokenTypes.JAVADOC_INLINE_TAG) {\ncontinue;\n}\nDetailNode customNameNode = JavadocUtil.findFirstToken(node, JavadocTokenTypes.CUSTOM_NAME);\nif (customNameNode == null || !CODE_SNIPPET_ANNOTATION.equals(customNameNode.getText())) {\nreturn;\n}\nDetailNode descriptionNode = JavadocUtil.findFirstToken(node, JavadocTokenTypes.DESCRIPTION);\nif (descriptionNode == null) {\nlog(node.getLineNumber(), MISSING_CODESNIPPET_TAG_MESSAGE);\nreturn;\n}\nString customDescription = JavadocUtil.findFirstToken(descriptionNode, JavadocTokenTypes.TEXT).getText();\nDetailAST methodDefToken = methodDefStack.peek();\nfinal String methodName = methodDefToken.findFirstToken(TokenTypes.IDENT).getText();\nfinal String className = classNameStack.isEmpty() ? \"\" : classNameStack.peek();\nfinal String parameters = constructParametersString(methodDefToken);\nString fullPath = packageName + \".\" + className + \".\" + methodName;\nif (parameters != null) {\nfullPath = fullPath + \"\n}\nif (customDescription == null || customDescription.isEmpty() ||\n!isNamingMatched(customDescription.toLowerCase(), fullPath.toLowerCase(), parameters)) {\nlog(node.getLineNumber(), String.format(\"Naming pattern mismatch. The @codeSnippet description \"\n+ \"''%s'' does not match ''%s''. Case Insensitive.\", customDescription, fullPath));\n}\n}\n}",
+ "target_code": "DetailAST methodDefToken = methodDefStack.peek();",
+ "method_body_after": "private void checkNamingPattern(DetailAST blockCommentToken) {\nif (!BlockCommentPosition.isOnMethod(blockCommentToken)) {\nreturn;\n}\nDetailNode javadocNode = null;\ntry {\njavadocNode = DetailNodeTreeStringPrinter.parseJavadocAsDetailNode(blockCommentToken);\n} catch (IllegalArgumentException ex) {\n}\nif (javadocNode == null) {\nreturn;\n}\nfor (DetailNode node : javadocNode.getChildren()) {\nif (node.getType() != JavadocTokenTypes.JAVADOC_INLINE_TAG) {\ncontinue;\n}\nDetailNode customNameNode = JavadocUtil.findFirstToken(node, JavadocTokenTypes.CUSTOM_NAME);\nif (customNameNode == null || !CODE_SNIPPET_ANNOTATION.equals(customNameNode.getText())) {\nreturn;\n}\nDetailNode descriptionNode = JavadocUtil.findFirstToken(node, JavadocTokenTypes.DESCRIPTION);\nif (descriptionNode == null) {\nlog(node.getLineNumber(), MISSING_CODESNIPPET_TAG_MESSAGE);\nreturn;\n}\nString customDescription = JavadocUtil.findFirstToken(descriptionNode, JavadocTokenTypes.TEXT).getText();\nfinal String methodName = methodDefToken.findFirstToken(TokenTypes.IDENT).getText();\nfinal String className = classNameStack.isEmpty() ? \"\" : classNameStack.peek();\nfinal String parameters = constructParametersString(methodDefToken);\nString fullPath = packageName + \".\" + className + \".\" + methodName;\nfinal String fullPathWithoutParameters = fullPath;\nif (parameters != null) {\nfullPath = fullPath + \"\n}\nif (customDescription == null || customDescription.isEmpty()\n|| !isNamingMatched(customDescription.toLowerCase(Locale.ROOT),\nfullPathWithoutParameters.toLowerCase(Locale.ROOT), parameters)) {\nlog(node.getLineNumber(), String.format(\"Naming pattern mismatch. The @codesnippet description \"\n+ \"''%s'' does not match ''%s''. Case Insensitive.\", customDescription, fullPath));\n}\n}\n}",
+ "context_before": "class name when leave the same token\nprivate Deque classNameStack = new ArrayDeque<>();\nprivate Deque methodDefStack = new ArrayDeque<>();\n@Override\npublic int[] getDefaultTokens() {\nreturn getRequiredTokens();\n}",
+ "context_after": "class name when leave the same token\nprivate Deque classNameStack = new ArrayDeque<>();\nprivate DetailAST methodDefToken = null;\n@Override\npublic int[] getDefaultTokens() {\nreturn getRequiredTokens();\n}"
+ },
+ {
+ "comment": "Please fix assertion by original `getIndexes`",
+ "method_body": "private void assertTableMetaDataMap(final Map actual) {\nassertThat(actual.size(), is(1));\nassertThat(actual.get(\"tbl\").getColumns().size(), is(2));\nassertThat(actual.get(\"tbl\").getColumnMetaData(0), is(new ColumnMetaData(\"id\", 4, true, true, true)));\nassertThat(actual.get(\"tbl\").getColumnMetaData(1), is(new ColumnMetaData(\"name\", 12, false, false, false)));\nassertThat(actual.get(\"tbl\").getIndexes().size(), is(1));\nassertThat(actual.get(\"tbl\").getIndexMetaData(0), is(new IndexMetaData(\"id\")));\n}",
+ "target_code": "assertThat(actual.get(\"tbl\").getIndexMetaData(0), is(new IndexMetaData(\"id\")));",
+ "method_body_after": "private void assertTableMetaDataMap(final Map actual) {\nassertThat(actual.size(), is(1));\nassertThat(actual.get(\"tbl\").getColumns().size(), is(2));\nassertThat(actual.get(\"tbl\").getColumnMetaData(0), is(new ColumnMetaData(\"id\", 4, true, true, true)));\nassertThat(actual.get(\"tbl\").getColumnMetaData(1), is(new ColumnMetaData(\"name\", 12, false, false, false)));\nassertThat(actual.get(\"tbl\").getIndexes().size(), is(1));\nassertThat(actual.get(\"tbl\").getIndexes().get(\"id\"), is(new IndexMetaData(\"id\")));\n}",
+ "context_before": "class MySQLTableMetaDataLoaderTest {\n@BeforeClass\npublic static void setUp() {\nShardingSphereServiceLoader.register(DialectTableMetaDataLoader.class);\n}\n@Test\npublic void assertLoadWithoutExistedTables() throws SQLException {\nDataSource dataSource = mockDataSource();\nResultSet resultSet = mockTableMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(resultSet);\nResultSet indexResultSet = mockIndexMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT INDEX_NAME FROM information_schema.statistics WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(indexResultSet);\nassertTableMetaDataMap(getTableMetaDataLoader().load(dataSource, Collections.emptyList()));\n}\n@Test\npublic void assertLoadWithExistedTables() throws SQLException {\nDataSource dataSource = mockDataSource();\nResultSet resultSet = mockTableMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=? AND TABLE_NAME NOT IN ('existed_tbl')\")\n.executeQuery()).thenReturn(resultSet);\nResultSet indexResultSet = mockIndexMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT INDEX_NAME FROM information_schema.statistics WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(indexResultSet);\nassertTableMetaDataMap(getTableMetaDataLoader().load(dataSource, Collections.singletonList(\"existed_tbl\")));\n}\nprivate DataSource mockDataSource() throws SQLException {\nDataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);\nResultSet typeInfoResultSet = mockTypeInfoResultSet();\nwhen(result.getConnection().getMetaData().getTypeInfo()).thenReturn(typeInfoResultSet);\nreturn result;\n}\nprivate ResultSet mockTypeInfoResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, true, false);\nwhen(result.getString(\"TYPE_NAME\")).thenReturn(\"int\", \"varchar\");\nwhen(result.getInt(\"DATA_TYPE\")).thenReturn(4, 12);\nreturn result;\n}\nprivate ResultSet mockTableMetaDataResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, true, false);\nwhen(result.getString(\"TABLE_NAME\")).thenReturn(\"tbl\");\nwhen(result.getString(\"COLUMN_NAME\")).thenReturn(\"id\", \"name\");\nwhen(result.getString(\"DATA_TYPE\")).thenReturn(\"int\", \"varchar\");\nwhen(result.getString(\"COLUMN_KEY\")).thenReturn(\"PRI\", \"\");\nwhen(result.getString(\"EXTRA\")).thenReturn(\"auto_increment\", \"\");\nwhen(result.getString(\"COLLATION_NAME\")).thenReturn(\"utf8_general_ci\", \"utf8\");\nreturn result;\n}\nprivate ResultSet mockIndexMetaDataResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, false, false);\nwhen(result.getString(\"INDEX_NAME\")).thenReturn(\"id\");\nreturn result;\n}\nprivate DialectTableMetaDataLoader getTableMetaDataLoader() {\nfor (DialectTableMetaDataLoader each : ShardingSphereServiceLoader.newServiceInstances(DialectTableMetaDataLoader.class)) {\nif (\"MySQL\".equals(each.getDatabaseType())) {\nreturn each;\n}\n}\nthrow new IllegalStateException(\"Can not find MySQLTableMetaDataLoader\");\n}\n}",
+ "context_after": "class MySQLTableMetaDataLoaderTest {\n@BeforeClass\npublic static void setUp() {\nShardingSphereServiceLoader.register(DialectTableMetaDataLoader.class);\n}\n@Test\npublic void assertLoadWithoutExistedTables() throws SQLException {\nDataSource dataSource = mockDataSource();\nResultSet resultSet = mockTableMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(resultSet);\nResultSet indexResultSet = mockIndexMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT INDEX_NAME FROM information_schema.statistics WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(indexResultSet);\nassertTableMetaDataMap(getTableMetaDataLoader().load(dataSource, Collections.emptyList()));\n}\n@Test\npublic void assertLoadWithExistedTables() throws SQLException {\nDataSource dataSource = mockDataSource();\nResultSet resultSet = mockTableMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_KEY, EXTRA, COLLATION_NAME FROM information_schema.columns WHERE TABLE_SCHEMA=? AND TABLE_NAME NOT IN ('existed_tbl')\")\n.executeQuery()).thenReturn(resultSet);\nResultSet indexResultSet = mockIndexMetaDataResultSet();\nwhen(dataSource.getConnection().prepareStatement(\n\"SELECT INDEX_NAME FROM information_schema.statistics WHERE TABLE_SCHEMA=?\").executeQuery()).thenReturn(indexResultSet);\nassertTableMetaDataMap(getTableMetaDataLoader().load(dataSource, Collections.singletonList(\"existed_tbl\")));\n}\nprivate DataSource mockDataSource() throws SQLException {\nDataSource result = mock(DataSource.class, RETURNS_DEEP_STUBS);\nResultSet typeInfoResultSet = mockTypeInfoResultSet();\nwhen(result.getConnection().getMetaData().getTypeInfo()).thenReturn(typeInfoResultSet);\nreturn result;\n}\nprivate ResultSet mockTypeInfoResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, true, false);\nwhen(result.getString(\"TYPE_NAME\")).thenReturn(\"int\", \"varchar\");\nwhen(result.getInt(\"DATA_TYPE\")).thenReturn(4, 12);\nreturn result;\n}\nprivate ResultSet mockTableMetaDataResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, true, false);\nwhen(result.getString(\"TABLE_NAME\")).thenReturn(\"tbl\");\nwhen(result.getString(\"COLUMN_NAME\")).thenReturn(\"id\", \"name\");\nwhen(result.getString(\"DATA_TYPE\")).thenReturn(\"int\", \"varchar\");\nwhen(result.getString(\"COLUMN_KEY\")).thenReturn(\"PRI\", \"\");\nwhen(result.getString(\"EXTRA\")).thenReturn(\"auto_increment\", \"\");\nwhen(result.getString(\"COLLATION_NAME\")).thenReturn(\"utf8_general_ci\", \"utf8\");\nreturn result;\n}\nprivate ResultSet mockIndexMetaDataResultSet() throws SQLException {\nResultSet result = mock(ResultSet.class);\nwhen(result.next()).thenReturn(true, false);\nwhen(result.getString(\"INDEX_NAME\")).thenReturn(\"id\");\nreturn result;\n}\nprivate DialectTableMetaDataLoader getTableMetaDataLoader() {\nfor (DialectTableMetaDataLoader each : ShardingSphereServiceLoader.newServiceInstances(DialectTableMetaDataLoader.class)) {\nif (\"MySQL\".equals(each.getDatabaseType())) {\nreturn each;\n}\n}\nthrow new IllegalStateException(\"Can not find MySQLTableMetaDataLoader\");\n}\n}"
+ },
+ {
+ "comment": "Can we just pass a flag into `BeamSqlLikeExpression`? ",
+ "method_body": "private static BeamSqlExpression getBeamSqlExpression(RexNode rexNode) {\nBeamSqlExpression ret;\nif (rexNode instanceof RexLiteral) {\nRexLiteral node = (RexLiteral) rexNode;\nSqlTypeName type = node.getTypeName();\nObject value = node.getValue();\nif (SqlTypeName.CHAR_TYPES.contains(type) && node.getValue() instanceof NlsString) {\nret = BeamSqlPrimitive.of(type, ((NlsString) value).getValue());\n} else if (isDateNode(type, value)) {\nret = BeamSqlPrimitive.of(type, new DateTime(((Calendar) value).getTimeInMillis()));\n} else {\nSqlTypeName realType = node.getType().getSqlTypeName();\nObject realValue = value;\nif (SqlTypeName.NUMERIC_TYPES.contains(type)) {\nswitch (realType) {\ncase TINYINT:\nrealValue = SqlFunctions.toByte(value);\nbreak;\ncase SMALLINT:\nrealValue = SqlFunctions.toShort(value);\nbreak;\ncase INTEGER:\nrealValue = SqlFunctions.toInt(value);\nbreak;\ncase BIGINT:\nrealValue = SqlFunctions.toLong(value);\nbreak;\ncase FLOAT:\nrealValue = SqlFunctions.toFloat(value);\nbreak;\ncase DOUBLE:\nrealValue = SqlFunctions.toDouble(value);\nbreak;\ncase DECIMAL:\nrealValue = SqlFunctions.toBigDecimal(value);\nbreak;\ndefault:\nthrow new IllegalStateException(\n\"Unsupported conversion: Attempted convert node \"\n+ node.toString()\n+ \" of type \"\n+ type\n+ \"to \"\n+ realType);\n}\n}\nret = BeamSqlPrimitive.of(realType, realValue);\n}\n} else if (rexNode instanceof RexInputRef) {\nRexInputRef node = (RexInputRef) rexNode;\nret = new BeamSqlInputRefExpression(node.getType().getSqlTypeName(), node.getIndex());\n} else if (rexNode instanceof RexCorrelVariable) {\nRexCorrelVariable correlVariable = (RexCorrelVariable) rexNode;\nret =\nnew BeamSqlCorrelVariableExpression(\ncorrelVariable.getType().getSqlTypeName(), correlVariable.id.getId());\n} else if (rexNode instanceof RexLocalRef) {\nRexLocalRef localRef = (RexLocalRef) rexNode;\nret = new BeamSqlLocalRefExpression(localRef.getType().getSqlTypeName(), localRef.getIndex());\n} else if (rexNode instanceof RexFieldAccess) {\nRexFieldAccess fieldAccessNode = (RexFieldAccess) rexNode;\nBeamSqlExpression referenceExpression = buildExpression(fieldAccessNode.getReferenceExpr());\nint nestedFieldIndex = fieldAccessNode.getField().getIndex();\nSqlTypeName nestedFieldType = fieldAccessNode.getField().getType().getSqlTypeName();\nret =\nnew BeamSqlFieldAccessExpression(referenceExpression, nestedFieldIndex, nestedFieldType);\n} else if (rexNode instanceof RexCall) {\nRexCall node = (RexCall) rexNode;\nString opName = node.op.getName();\nList subExps = new ArrayList<>();\nfor (RexNode subNode : node.getOperands()) {\nsubExps.add(buildExpression(subNode));\n}\nswitch (opName) {\ncase \"AND\":\nret = new BeamSqlAndExpression(subExps);\nbreak;\ncase \"OR\":\nret = new BeamSqlOrExpression(subExps);\nbreak;\ncase \"NOT\":\nret = new BeamSqlNotExpression(subExps);\nbreak;\ncase \"=\":\nret = new BeamSqlEqualsExpression(subExps);\nbreak;\ncase \"<>\":\nret = new BeamSqlNotEqualsExpression(subExps);\nbreak;\ncase \">\":\nret = new BeamSqlGreaterThanExpression(subExps);\nbreak;\ncase \">=\":\nret = new BeamSqlGreaterThanOrEqualsExpression(subExps);\nbreak;\ncase \"<\":\nret = new BeamSqlLessThanExpression(subExps);\nbreak;\ncase \"<=\":\nret = new BeamSqlLessThanOrEqualsExpression(subExps);\nbreak;\ncase \"LIKE\":\nret = new BeamSqlLikeExpression(subExps);\nbreak;\ncase \"NOT LIKE\":\nret = new BeamSqlNotLikeExpression(subExps);\nbreak;\ncase \"+\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlPlusExpression(subExps);\n} else {\nret = new BeamSqlDatetimePlusExpression(subExps);\n}\nbreak;\ncase \"-\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlMinusExpression(subExps);\n} else {\nret = new BeamSqlDatetimeMinusExpression(subExps, node.type.getSqlTypeName());\n}\nbreak;\ncase \"*\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlMultiplyExpression(subExps);\n} else {\nret = new BeamSqlIntervalMultiplyExpression(subExps);\n}\nbreak;\ncase \"/\":\ncase \"/INT\":\nret = new BeamSqlDivideExpression(subExps);\nbreak;\ncase \"MOD\":\nret = new BeamSqlModExpression(subExps);\nbreak;\ncase \"ABS\":\nret = new BeamSqlAbsExpression(subExps);\nbreak;\ncase \"ROUND\":\nret = new BeamSqlRoundExpression(subExps);\nbreak;\ncase \"LN\":\nret = new BeamSqlLnExpression(subExps);\nbreak;\ncase \"LOG10\":\nret = new BeamSqlLogExpression(subExps);\nbreak;\ncase \"EXP\":\nret = new BeamSqlExpExpression(subExps);\nbreak;\ncase \"ACOS\":\nret = new BeamSqlAcosExpression(subExps);\nbreak;\ncase \"ASIN\":\nret = new BeamSqlAsinExpression(subExps);\nbreak;\ncase \"ATAN\":\nret = new BeamSqlAtanExpression(subExps);\nbreak;\ncase \"COT\":\nret = new BeamSqlCotExpression(subExps);\nbreak;\ncase \"DEGREES\":\nret = new BeamSqlDegreesExpression(subExps);\nbreak;\ncase \"RADIANS\":\nret = new BeamSqlRadiansExpression(subExps);\nbreak;\ncase \"COS\":\nret = new BeamSqlCosExpression(subExps);\nbreak;\ncase \"SIN\":\nret = new BeamSqlSinExpression(subExps);\nbreak;\ncase \"TAN\":\nret = new BeamSqlTanExpression(subExps);\nbreak;\ncase \"SIGN\":\nret = new BeamSqlSignExpression(subExps);\nbreak;\ncase \"POWER\":\nret = new BeamSqlPowerExpression(subExps);\nbreak;\ncase \"PI\":\nret = new BeamSqlPiExpression();\nbreak;\ncase \"ATAN2\":\nret = new BeamSqlAtan2Expression(subExps);\nbreak;\ncase \"TRUNCATE\":\nret = new BeamSqlTruncateExpression(subExps);\nbreak;\ncase \"RAND\":\nret = new BeamSqlRandExpression(subExps);\nbreak;\ncase \"RAND_INTEGER\":\nret = new BeamSqlRandIntegerExpression(subExps);\nbreak;\ncase \"||\":\nret = new BeamSqlOperatorExpression(StringOperators.CONCAT, subExps);\nbreak;\ncase \"POSITION\":\nret = new BeamSqlOperatorExpression(StringOperators.POSITION, subExps);\nbreak;\ncase \"CHAR_LENGTH\":\ncase \"CHARACTER_LENGTH\":\nret = new BeamSqlOperatorExpression(StringOperators.CHAR_LENGTH, subExps);\nbreak;\ncase \"UPPER\":\nret = new BeamSqlOperatorExpression(StringOperators.UPPER, subExps);\nbreak;\ncase \"LOWER\":\nret = new BeamSqlOperatorExpression(StringOperators.LOWER, subExps);\nbreak;\ncase \"TRIM\":\nret = new BeamSqlOperatorExpression(StringOperators.TRIM, subExps);\nbreak;\ncase \"SUBSTRING\":\nret = new BeamSqlOperatorExpression(StringOperators.SUBSTRING, subExps);\nbreak;\ncase \"OVERLAY\":\nret = new BeamSqlOperatorExpression(StringOperators.OVERLAY, subExps);\nbreak;\ncase \"INITCAP\":\nret = new BeamSqlOperatorExpression(StringOperators.INIT_CAP, subExps);\nbreak;\ncase \"Reinterpret\":\nret = new BeamSqlReinterpretExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"CEIL\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlCeilExpression(subExps);\n} else {\nret = new BeamSqlOperatorExpression(DateOperators.DATETIME_CEIL, subExps);\n}\nbreak;\ncase \"FLOOR\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlFloorExpression(subExps);\n} else {\nret = new BeamSqlOperatorExpression(DateOperators.DATETIME_FLOOR, subExps);\n}\nbreak;\ncase \"EXTRACT_DATE\":\ncase \"EXTRACT\":\nret = new BeamSqlOperatorExpression(DateOperators.EXTRACT, subExps);\nbreak;\ncase \"LOCALTIME\":\ncase \"CURRENT_TIME\":\nret = new BeamSqlCurrentTimeExpression(subExps);\nbreak;\ncase \"CURRENT_TIMESTAMP\":\ncase \"LOCALTIMESTAMP\":\nret = new BeamSqlCurrentTimestampExpression(subExps);\nbreak;\ncase \"CURRENT_DATE\":\nret = new BeamSqlCurrentDateExpression();\nbreak;\ncase \"DATETIME_PLUS\":\nret = new BeamSqlDatetimePlusExpression(subExps);\nbreak;\ncase \"ARRAY\":\nret = new BeamSqlArrayExpression(subExps);\nbreak;\ncase \"MAP\":\nret = new BeamSqlMapExpression(subExps);\nbreak;\ncase \"ITEM\":\nswitch (subExps.get(0).getOutputType()) {\ncase MAP:\nret = new BeamSqlMapItemExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase ARRAY:\nret = new BeamSqlArrayItemExpression(subExps, node.type.getSqlTypeName());\nbreak;\ndefault:\nthrow new UnsupportedOperationException(\n\"Operator: \" + opName + \" is not supported yet\");\n}\nbreak;\ncase \"ELEMENT\":\nret = new BeamSqlSingleElementExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"CARDINALITY\":\nret = new BeamSqlCardinalityExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"DOT\":\nret = new BeamSqlDotExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"DEFAULT\":\nret = new BeamSqlDefaultExpression();\nbreak;\ncase \"CASE\":\nret = new BeamSqlCaseExpression(subExps);\nbreak;\ncase \"CAST\":\nret = new BeamSqlCastExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"IS NULL\":\nret = new BeamSqlIsNullExpression(subExps.get(0));\nbreak;\ncase \"IS NOT NULL\":\nret = new BeamSqlIsNotNullExpression(subExps.get(0));\nbreak;\ncase \"HOP\":\ncase \"TUMBLE\":\ncase \"SESSION\":\nret = new BeamSqlWindowExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"HOP_START\":\ncase \"TUMBLE_START\":\ncase \"SESSION_START\":\nret = new BeamSqlWindowStartExpression();\nbreak;\ncase \"HOP_END\":\ncase \"TUMBLE_END\":\ncase \"SESSION_END\":\nret = new BeamSqlWindowEndExpression();\nbreak;\ndefault:\nif (((RexCall) rexNode).getOperator() instanceof SqlUserDefinedFunction) {\nSqlUserDefinedFunction udf = (SqlUserDefinedFunction) ((RexCall) rexNode).getOperator();\nScalarFunctionImpl fn = (ScalarFunctionImpl) udf.getFunction();\nret =\nnew BeamSqlUdfExpression(\nfn.method, subExps, ((RexCall) rexNode).type.getSqlTypeName());\n} else {\nthrow new UnsupportedOperationException(\n\"Operator: \" + opName + \" is not supported yet\");\n}\n}\n} else {\nthrow new UnsupportedOperationException(\nString.format(\"%s is not supported yet\", rexNode.getClass().toString()));\n}\nreturn ret;\n}",
+ "target_code": "ret = new BeamSqlNotLikeExpression(subExps);",
+ "method_body_after": "private static BeamSqlExpression getBeamSqlExpression(RexNode rexNode) {\nBeamSqlExpression ret;\nif (rexNode instanceof RexLiteral) {\nRexLiteral node = (RexLiteral) rexNode;\nSqlTypeName type = node.getTypeName();\nObject value = node.getValue();\nif (SqlTypeName.CHAR_TYPES.contains(type) && node.getValue() instanceof NlsString) {\nret = BeamSqlPrimitive.of(type, ((NlsString) value).getValue());\n} else if (isDateNode(type, value)) {\nret = BeamSqlPrimitive.of(type, new DateTime(((Calendar) value).getTimeInMillis()));\n} else {\nSqlTypeName realType = node.getType().getSqlTypeName();\nObject realValue = value;\nif (SqlTypeName.NUMERIC_TYPES.contains(type)) {\nswitch (realType) {\ncase TINYINT:\nrealValue = SqlFunctions.toByte(value);\nbreak;\ncase SMALLINT:\nrealValue = SqlFunctions.toShort(value);\nbreak;\ncase INTEGER:\nrealValue = SqlFunctions.toInt(value);\nbreak;\ncase BIGINT:\nrealValue = SqlFunctions.toLong(value);\nbreak;\ncase FLOAT:\nrealValue = SqlFunctions.toFloat(value);\nbreak;\ncase DOUBLE:\nrealValue = SqlFunctions.toDouble(value);\nbreak;\ncase DECIMAL:\nrealValue = SqlFunctions.toBigDecimal(value);\nbreak;\ndefault:\nthrow new IllegalStateException(\n\"Unsupported conversion: Attempted convert node \"\n+ node.toString()\n+ \" of type \"\n+ type\n+ \"to \"\n+ realType);\n}\n}\nret = BeamSqlPrimitive.of(realType, realValue);\n}\n} else if (rexNode instanceof RexInputRef) {\nRexInputRef node = (RexInputRef) rexNode;\nret = new BeamSqlInputRefExpression(node.getType().getSqlTypeName(), node.getIndex());\n} else if (rexNode instanceof RexCorrelVariable) {\nRexCorrelVariable correlVariable = (RexCorrelVariable) rexNode;\nret =\nnew BeamSqlCorrelVariableExpression(\ncorrelVariable.getType().getSqlTypeName(), correlVariable.id.getId());\n} else if (rexNode instanceof RexLocalRef) {\nRexLocalRef localRef = (RexLocalRef) rexNode;\nret = new BeamSqlLocalRefExpression(localRef.getType().getSqlTypeName(), localRef.getIndex());\n} else if (rexNode instanceof RexFieldAccess) {\nRexFieldAccess fieldAccessNode = (RexFieldAccess) rexNode;\nBeamSqlExpression referenceExpression = buildExpression(fieldAccessNode.getReferenceExpr());\nint nestedFieldIndex = fieldAccessNode.getField().getIndex();\nSqlTypeName nestedFieldType = fieldAccessNode.getField().getType().getSqlTypeName();\nret =\nnew BeamSqlFieldAccessExpression(referenceExpression, nestedFieldIndex, nestedFieldType);\n} else if (rexNode instanceof RexCall) {\nRexCall node = (RexCall) rexNode;\nString opName = node.op.getName();\nList subExps = new ArrayList<>();\nfor (RexNode subNode : node.getOperands()) {\nsubExps.add(buildExpression(subNode));\n}\nswitch (opName) {\ncase \"AND\":\nret = new BeamSqlAndExpression(subExps);\nbreak;\ncase \"OR\":\nret = new BeamSqlOrExpression(subExps);\nbreak;\ncase \"NOT\":\nret = new BeamSqlNotExpression(subExps);\nbreak;\ncase \"=\":\nret = new BeamSqlEqualsExpression(subExps);\nbreak;\ncase \"<>\":\nret = new BeamSqlNotEqualsExpression(subExps);\nbreak;\ncase \">\":\nret = new BeamSqlGreaterThanExpression(subExps);\nbreak;\ncase \">=\":\nret = new BeamSqlGreaterThanOrEqualsExpression(subExps);\nbreak;\ncase \"<\":\nret = new BeamSqlLessThanExpression(subExps);\nbreak;\ncase \"<=\":\nret = new BeamSqlLessThanOrEqualsExpression(subExps);\nbreak;\ncase \"LIKE\":\nret = new BeamSqlLikeExpression(subExps);\nbreak;\ncase \"NOT LIKE\":\nret = new BeamSqlNotLikeExpression(subExps);\nbreak;\ncase \"+\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlPlusExpression(subExps);\n} else {\nret = new BeamSqlDatetimePlusExpression(subExps);\n}\nbreak;\ncase \"-\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlMinusExpression(subExps);\n} else {\nret = new BeamSqlDatetimeMinusExpression(subExps, node.type.getSqlTypeName());\n}\nbreak;\ncase \"*\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlMultiplyExpression(subExps);\n} else {\nret = new BeamSqlIntervalMultiplyExpression(subExps);\n}\nbreak;\ncase \"/\":\ncase \"/INT\":\nret = new BeamSqlDivideExpression(subExps);\nbreak;\ncase \"MOD\":\nret = new BeamSqlModExpression(subExps);\nbreak;\ncase \"ABS\":\nret = new BeamSqlAbsExpression(subExps);\nbreak;\ncase \"ROUND\":\nret = new BeamSqlRoundExpression(subExps);\nbreak;\ncase \"LN\":\nret = new BeamSqlLnExpression(subExps);\nbreak;\ncase \"LOG10\":\nret = new BeamSqlLogExpression(subExps);\nbreak;\ncase \"EXP\":\nret = new BeamSqlExpExpression(subExps);\nbreak;\ncase \"ACOS\":\nret = new BeamSqlAcosExpression(subExps);\nbreak;\ncase \"ASIN\":\nret = new BeamSqlAsinExpression(subExps);\nbreak;\ncase \"ATAN\":\nret = new BeamSqlAtanExpression(subExps);\nbreak;\ncase \"COT\":\nret = new BeamSqlCotExpression(subExps);\nbreak;\ncase \"DEGREES\":\nret = new BeamSqlDegreesExpression(subExps);\nbreak;\ncase \"RADIANS\":\nret = new BeamSqlRadiansExpression(subExps);\nbreak;\ncase \"COS\":\nret = new BeamSqlCosExpression(subExps);\nbreak;\ncase \"SIN\":\nret = new BeamSqlSinExpression(subExps);\nbreak;\ncase \"TAN\":\nret = new BeamSqlTanExpression(subExps);\nbreak;\ncase \"SIGN\":\nret = new BeamSqlSignExpression(subExps);\nbreak;\ncase \"POWER\":\nret = new BeamSqlPowerExpression(subExps);\nbreak;\ncase \"PI\":\nret = new BeamSqlPiExpression();\nbreak;\ncase \"ATAN2\":\nret = new BeamSqlAtan2Expression(subExps);\nbreak;\ncase \"TRUNCATE\":\nret = new BeamSqlTruncateExpression(subExps);\nbreak;\ncase \"RAND\":\nret = new BeamSqlRandExpression(subExps);\nbreak;\ncase \"RAND_INTEGER\":\nret = new BeamSqlRandIntegerExpression(subExps);\nbreak;\ncase \"||\":\nret = new BeamSqlOperatorExpression(StringOperators.CONCAT, subExps);\nbreak;\ncase \"POSITION\":\nret = new BeamSqlOperatorExpression(StringOperators.POSITION, subExps);\nbreak;\ncase \"CHAR_LENGTH\":\ncase \"CHARACTER_LENGTH\":\nret = new BeamSqlOperatorExpression(StringOperators.CHAR_LENGTH, subExps);\nbreak;\ncase \"UPPER\":\nret = new BeamSqlOperatorExpression(StringOperators.UPPER, subExps);\nbreak;\ncase \"LOWER\":\nret = new BeamSqlOperatorExpression(StringOperators.LOWER, subExps);\nbreak;\ncase \"TRIM\":\nret = new BeamSqlOperatorExpression(StringOperators.TRIM, subExps);\nbreak;\ncase \"SUBSTRING\":\nret = new BeamSqlOperatorExpression(StringOperators.SUBSTRING, subExps);\nbreak;\ncase \"OVERLAY\":\nret = new BeamSqlOperatorExpression(StringOperators.OVERLAY, subExps);\nbreak;\ncase \"INITCAP\":\nret = new BeamSqlOperatorExpression(StringOperators.INIT_CAP, subExps);\nbreak;\ncase \"Reinterpret\":\nret = new BeamSqlReinterpretExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"CEIL\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlCeilExpression(subExps);\n} else {\nret = new BeamSqlOperatorExpression(DateOperators.DATETIME_CEIL, subExps);\n}\nbreak;\ncase \"FLOOR\":\nif (SqlTypeName.NUMERIC_TYPES.contains(node.type.getSqlTypeName())) {\nret = new BeamSqlFloorExpression(subExps);\n} else {\nret = new BeamSqlOperatorExpression(DateOperators.DATETIME_FLOOR, subExps);\n}\nbreak;\ncase \"EXTRACT_DATE\":\ncase \"EXTRACT\":\nret = new BeamSqlOperatorExpression(DateOperators.EXTRACT, subExps);\nbreak;\ncase \"LOCALTIME\":\ncase \"CURRENT_TIME\":\nret = new BeamSqlCurrentTimeExpression(subExps);\nbreak;\ncase \"CURRENT_TIMESTAMP\":\ncase \"LOCALTIMESTAMP\":\nret = new BeamSqlCurrentTimestampExpression(subExps);\nbreak;\ncase \"CURRENT_DATE\":\nret = new BeamSqlCurrentDateExpression();\nbreak;\ncase \"DATETIME_PLUS\":\nret = new BeamSqlDatetimePlusExpression(subExps);\nbreak;\ncase \"ARRAY\":\nret = new BeamSqlArrayExpression(subExps);\nbreak;\ncase \"MAP\":\nret = new BeamSqlMapExpression(subExps);\nbreak;\ncase \"ITEM\":\nswitch (subExps.get(0).getOutputType()) {\ncase MAP:\nret = new BeamSqlMapItemExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase ARRAY:\nret = new BeamSqlArrayItemExpression(subExps, node.type.getSqlTypeName());\nbreak;\ndefault:\nthrow new UnsupportedOperationException(\n\"Operator: \" + opName + \" is not supported yet\");\n}\nbreak;\ncase \"ELEMENT\":\nret = new BeamSqlSingleElementExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"CARDINALITY\":\nret = new BeamSqlCardinalityExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"DOT\":\nret = new BeamSqlDotExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"DEFAULT\":\nret = new BeamSqlDefaultExpression();\nbreak;\ncase \"CASE\":\nret = new BeamSqlCaseExpression(subExps);\nbreak;\ncase \"CAST\":\nret = new BeamSqlCastExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"IS NULL\":\nret = new BeamSqlIsNullExpression(subExps.get(0));\nbreak;\ncase \"IS NOT NULL\":\nret = new BeamSqlIsNotNullExpression(subExps.get(0));\nbreak;\ncase \"HOP\":\ncase \"TUMBLE\":\ncase \"SESSION\":\nret = new BeamSqlWindowExpression(subExps, node.type.getSqlTypeName());\nbreak;\ncase \"HOP_START\":\ncase \"TUMBLE_START\":\ncase \"SESSION_START\":\nret = new BeamSqlWindowStartExpression();\nbreak;\ncase \"HOP_END\":\ncase \"TUMBLE_END\":\ncase \"SESSION_END\":\nret = new BeamSqlWindowEndExpression();\nbreak;\ndefault:\nif (((RexCall) rexNode).getOperator() instanceof SqlUserDefinedFunction) {\nSqlUserDefinedFunction udf = (SqlUserDefinedFunction) ((RexCall) rexNode).getOperator();\nScalarFunctionImpl fn = (ScalarFunctionImpl) udf.getFunction();\nret =\nnew BeamSqlUdfExpression(\nfn.method, subExps, ((RexCall) rexNode).type.getSqlTypeName());\n} else {\nthrow new UnsupportedOperationException(\n\"Operator: \" + opName + \" is not supported yet\");\n}\n}\n} else {\nthrow new UnsupportedOperationException(\nString.format(\"%s is not supported yet\", rexNode.getClass().toString()));\n}\nreturn ret;\n}",
+ "context_before": "class BeamSqlFnExecutor implements BeamSqlExpressionExecutor {\nprivate List exprs;\nprivate BeamSqlExpression filterCondition;\nprivate List projections;\npublic BeamSqlFnExecutor(RexProgram program) {\nthis.exprs =\nprogram\n.getExprList()\n.stream()\n.map(BeamSqlFnExecutor::buildExpression)\n.collect(Collectors.toList());\nthis.filterCondition =\nprogram.getCondition() == null\n? BeamSqlPrimitive.of(SqlTypeName.BOOLEAN, true)\n: buildExpression(program.getCondition());\nthis.projections =\nprogram\n.getProjectList()\n.stream()\n.map(BeamSqlFnExecutor::buildExpression)\n.collect(Collectors.toList());\n}\n/**\n* {@link\n* represent each {@link SqlOperator} with a corresponding {@link BeamSqlExpression}.\n*/\nstatic BeamSqlExpression buildExpression(RexNode rexNode) {\nBeamSqlExpression ret = getBeamSqlExpression(rexNode);\nif (!ret.accept()) {\nthrow new IllegalStateException(\nret.getClass().getSimpleName() + \" does not accept the operands.(\" + rexNode + \")\");\n}\nreturn ret;\n}\nprivate static boolean isDateNode(SqlTypeName type, Object value) {\nreturn (type == SqlTypeName.DATE || type == SqlTypeName.TIMESTAMP) && value instanceof Calendar;\n}\n@Override\npublic void prepare() {}\n@Override\npublic @Nullable List