rdblue commented on a change in pull request #1531:
URL: https://github.com/apache/iceberg/pull/1531#discussion_r499919640



##########
File path: core/src/main/java/org/apache/iceberg/LocationProviders.java
##########
@@ -36,7 +37,29 @@ private LocationProviders() {
   }
 
   public static LocationProvider locationsFor(String location, Map<String, 
String> properties) {
-    if (PropertyUtil.propertyAsBoolean(properties,
+    if (properties.containsKey(TableProperties.WRITE_LOCATION_PROVIDER_IMPL)) {
+      String impl = 
properties.get(TableProperties.WRITE_LOCATION_PROVIDER_IMPL);
+      DynConstructors.Ctor<LocationProvider> ctor;
+      try {
+        ctor = DynConstructors.builder(LocationProvider.class)
+            .impl(impl, String.class, Map.class)
+            .impl(impl).build(); // fall back to no-arg constructor
+      } catch (RuntimeException e) {
+        throw new IllegalArgumentException(String.format(
+            "Unable to find a constructor for implementation %s of %s. " +
+                "Make sure the implementation is in classpath, and that it 
either " +
+                "has a public no-arg constructor or a two-arg constructor " +
+                "taking in the string base table location and its property 
string map.",
+            impl, LocationProvider.class));
+      }
+      try {
+        return ctor.newInstance(location, properties);
+      } catch (ClassCastException e) {
+        throw new IllegalArgumentException(
+            String.format("Provided implementation for dynamic instantiation 
should implement %s, " +
+                "but found dynamic constructor %s.", LocationProvider.class, 
ctor));

Review comment:
       Dynamic constructor?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to