Search in sources :

Example 1 with JSONFormatConfig

use of org.apache.drill.exec.store.easy.json.JSONFormatPlugin.JSONFormatConfig in project drill by apache.

the class DropboxFileSystemTest method setup.

/*
   All test files can be found in java-exec/src/test/resources/dropboxTestFiles

  Instructions for running Dropbox Unit Tests
  1.  Get your Dropbox API key as explained in the Drill docs and paste it above into the ACCESS_TOKEN variable.
  2.  In your dropbox account, create a folder called 'csv' and upload the file hdf-test.csvh into that folder
  3.  In your dropbox account, upload the file http-pcap.json to the root directory of your dropbox account
  4.  In the testListFiles test, you will have to update the modified dates
  5.  Run tests.
   */
@BeforeClass
public static void setup() throws Exception {
    assertTrue(!ACCESS_TOKEN.equalsIgnoreCase("<Your Dropbox Access Token Here>"));
    ClusterTest.startCluster(ClusterFixture.builder(dirTestWatcher));
    Map<String, String> dropboxConfigVars = new HashMap<>();
    dropboxConfigVars.put("dropboxAccessToken", ACCESS_TOKEN);
    // Create workspaces
    WorkspaceConfig rootWorkspace = new WorkspaceConfig("/", false, null, false);
    WorkspaceConfig csvWorkspace = new WorkspaceConfig("/csv", false, null, false);
    Map<String, WorkspaceConfig> workspaces = new HashMap<>();
    workspaces.put("root", rootWorkspace);
    workspaces.put("csv", csvWorkspace);
    // Add formats
    Map<String, FormatPluginConfig> formats = new HashMap<>();
    List<String> jsonExtensions = new ArrayList<>();
    jsonExtensions.add("json");
    FormatPluginConfig jsonFormatConfig = new JSONFormatConfig(jsonExtensions);
    // CSV Format
    List<String> csvExtensions = new ArrayList<>();
    csvExtensions.add("csv");
    csvExtensions.add("csvh");
    FormatPluginConfig csvFormatConfig = new TextFormatConfig(csvExtensions, "\n", ",", "\"", null, null, false, true);
    StoragePluginConfig dropboxConfig = new FileSystemConfig("dropbox:///", dropboxConfigVars, workspaces, formats, null);
    dropboxConfig.setEnabled(true);
    cluster.defineStoragePlugin("dropbox_test", dropboxConfig);
    cluster.defineFormat("dropbox_test", "json", jsonFormatConfig);
    cluster.defineFormat("dropbox_test", "csv", csvFormatConfig);
}
Also used : HashMap(java.util.HashMap) TextFormatConfig(org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig) ArrayList(java.util.ArrayList) JSONFormatConfig(org.apache.drill.exec.store.easy.json.JSONFormatPlugin.JSONFormatConfig) FormatPluginConfig(org.apache.drill.common.logical.FormatPluginConfig) WorkspaceConfig(org.apache.drill.exec.store.dfs.WorkspaceConfig) StoragePluginConfig(org.apache.drill.common.logical.StoragePluginConfig) FileSystemConfig(org.apache.drill.exec.store.dfs.FileSystemConfig) BeforeClass(org.junit.BeforeClass)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FormatPluginConfig (org.apache.drill.common.logical.FormatPluginConfig)1 StoragePluginConfig (org.apache.drill.common.logical.StoragePluginConfig)1 FileSystemConfig (org.apache.drill.exec.store.dfs.FileSystemConfig)1 WorkspaceConfig (org.apache.drill.exec.store.dfs.WorkspaceConfig)1 JSONFormatConfig (org.apache.drill.exec.store.easy.json.JSONFormatPlugin.JSONFormatConfig)1 TextFormatConfig (org.apache.drill.exec.store.easy.text.TextFormatPlugin.TextFormatConfig)1 BeforeClass (org.junit.BeforeClass)1