class TrendAction extends Action<TrendRequest> {

    @Override
    public ActionResponse execute(TrendRequest parameter) throws QueryStoreException {
        parameter.setTable(ElasticsearchUtils.getValidTableName(parameter.getTable()));
        if (null == parameter.getFilters()) {
            parameter.setFilters(Lists.<Filter>newArrayList(new AnyFilter(parameter.getTable())));
        }
        String field = parameter.getField();
        if (parameter.getTable() == null) {
            throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Invalid table name");
        }
        if (null == field || field.isEmpty()) {
            throw new QueryStoreException(QueryStoreException.ErrorCode.INVALID_REQUEST, "Invalid field name");
        }
        if (null != parameter.getValues() && parameter.getValues().size() != 0) {
            List<Object> values = (List) parameter.getValues();
            Filter filter = new InFilter(field, values);
            parameter.getFilters().add(filter);
        }

        try {
            AbstractAggregationBuilder aggregationBuilder = buildAggregation(parameter);
            SearchResponse searchResponse = getConnection().getClient()
                    .prepareSearch(ElasticsearchUtils.getIndices(parameter.getTable(), parameter))
                    .setQuery(new ElasticSearchQueryGenerator(FilterCombinerType.and).genFilter(parameter.getFilters()))
                    .setSearchType(SearchType.COUNT)
                    .addAggregation(aggregationBuilder)
                    .execute()
                    .get();

            Aggregations aggregations = searchResponse.getAggregations();
            if (aggregations != null) {
                return buildResponse(parameter, aggregations);
            } else {
                logger.error("Null response for Trend. Request : " + parameter.toString());
                return new TrendResponse(Collections.<String, List<TrendResponse.Count>>emptyMap());
            }
        } catch (Exception e) {
            logger.error("Error running trend action: ", e);
            throw new QueryStoreException(QueryStoreException.ErrorCode.QUERY_EXECUTION_ERROR,
                    "Error running trend action.", e);
        }
    }

    public  TrendAction(TrendRequest parameter,
                       TableMetadataManager tableMetadataManager,
                       DataStore dataStore,
                       QueryStore queryStore,
                       ElasticsearchConnection connection,
                       String cacheToken);

}