Hi Charles,

I seem to recall fighting with something similar in the past. The problem is 
not with your setup; it is with how Drill finds your (custom?) UDF on the 
classpath.

My memory is hazy; but I think it had to do with the way that Drill uses the 
drill-override.conf file to extend class path scanning, and how it finds the 
UDF code. I think I banged on it until it worked, but I don't recall what I did.

Maybe I do remember. I think that, to run your code in the IDE, you need to add 
the source code directory to your class path. (Recall that Drill needs access 
to both function source and compiled code.) I think I modified my IDE debug 
launch command to always include the proper sources. I don't have that config 
in front of me; I'll check it this weekend to see if I can find the exact item 
you must add.

A workaround may be to run the test using Maven [1], since the Maven configs 
will do the needed magic:

cd exec/java-exec
mvn surefire:test -Dtest=YourTest


The other possibility is that you have your UDF in the "contrib" project, while 
you are running unit tests in the "exec" project. Exec does not depend on 
contrib, so contrib code is not visible to unit tests in Exec. The same is 
true, by the way, for the us of the JDBC driver, since that is in the Maven 
project after exec.

Thanks,
- Paul

[1] 
https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html


 

    On Friday, September 20, 2019, 07:44:55 AM PDT, Charles Givre 
<cgi...@gmail.com> wrote:  
 
 Hello Drillers, 
I'm encountering a strange error in a unit test.  The code is included below, 
and it fails because when Drill attempts to execute the test, it cannot find 
the function st_astext().  If I build Drill and execute the query in the CLI it 
works, so I suspect there is some environment issue rather than a Drill issue.  
Does anyone have any suggestions?
Thanks!


@BeforeClass
public static void setup() throws Exception {
  startCluster(ClusterFixture.builder(dirTestWatcher));

  DrillbitContext context = cluster.drillbit().getContext();
  FileSystemConfig original = (FileSystemConfig) 
context.getStorage().getPlugin("cp").getConfig();
  Map<String, FormatPluginConfig> newFormats = new 
HashMap<>(original.getFormats());
  newFormats.put("shp", new ShpFormatConfig());
  FileSystemConfig pluginConfig = new 
FileSystemConfig(original.getConnection(), original.getConfig(), 
original.getWorkspaces(), newFormats);
  pluginConfig.setEnabled(true);
  context.getStorage().createOrUpdate("cp", pluginConfig, true);
}
...

@Test
public void testShpQuery() throws Exception {

  testBuilder()
    .sqlQuery("select gid, srid, shapeType, name, st_astext(geom) as wkt "
      + "from cp.`CA-cities.shp` where gid = 100")
    .ordered()
    .baselineColumns("gid", "srid", "shapeType", "name", "wkt")
    .baselineValues(100, 4326, "Point", "Jenny Lind", "POINT (-120.8699371 
38.0949216)")
    .build()
    .run();
}
  

Reply via email to