# This is am example configuration file for Pivot, here you can add data sources as well as configure Pivot settings
# You can start by using this sample config by running `cp config_sample.yaml config.yaml`

# The port on which the Pivot server will listen on
port: 9090

# Run in verbose mode and print the queries sent to the server
verbose: true

# A Druid broker node that can serve data (only used if you have Druid based data source)
druidHost: localhost:8082

# A timeout for the Druid queries in ms (default: 30000 = 30 seconds)
timeout: 30000

sourceListRefreshOnLoad: true
sourceListRefreshInterval: 0 #10000

introspectionStrategy: datasource-get
sourceListScan: disable

#headerBackground: '#ffc000'

# The data sources that you have configured, these will appear, in order, inside the navigation menu of Pivot
# In general there can be two types of 'engine':
#   - native: a JSON file that is crunched within plywood itself (useful for small datasets and testing)
#   - druid: a Druid dataSource
dataSources:

  # Here is an example of a Druid data source, this one is taken from the Druid wikipedia demo
  # It will work for you if you have setup the demo Wikipedia Editstream scraper
  - name: wiki
    title: Wikipedia Edits
    engine: druid # Set the engine to druid
    source: wikipedia # The druid dataSource

    introspection: none

    # This is a real time data source so always assume it is up to date
    refreshRule:
      rule: realtime

    #subsetFilter: $language == 'de'

    options:
      customAggregations:
        test:
          aggregation:
            type: longSum
            fieldName: count

    attributeOverrides:
      - name: delta_hist
        special: histogram

    # All the dimensions will be automatically filled in from the data source
    dimensions:
      - name: __time
        kind: time

      - name: is-english
        expression: $language == 'en'

      - name: user-number
        expression: $user.extract("(\d+)")

      - name: user-first-letter
        expression: $user.substr(0, 1)

      - name: language
        expression: $language.lookup('wikipedia-language-lookup')

    measures:
      - name: count

      - name: distinct
        expression: $main.countDistinct($user_unique)
