<commit_before>package com.epam.ta.reportportal.dao.widget.healthcheck.query;

import com.epam.ta.reportportal.entity.widget.content.healthcheck.HealthCheckTableGetParams;
import com.google.common.collect.Sets;
import org.jooq.*;
import org.jooq.impl.DSL;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

import static com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants.*;
import static com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
@Component
public class CustomColumnQueryProvider extends AbstractHealthCheckTableQueryProvider {

	private static final String UNNESTED_ARRAY = "unnested_array";

	public CustomColumnQueryProvider() {
		super(Sets.newHashSet(CUSTOM_COLUMN_SORTING));
	}

	@Override
	protected Select<? extends Record> contentQuery(HealthCheckTableGetParams params, List<Condition> levelConditions) {
		SelectHavingStep<?> selectQuery = DSL.select(DSL.arrayAggDistinct(fieldName(UNNESTED_ARRAY)).as(AGGREGATED_VALUES),
				fieldName(VALUE)
		)
				.from(DSL.table(params.getViewName()), DSL.table(DSL.sql("unnest(?)", fieldName(CUSTOM_COLUMN))).as(UNNESTED_ARRAY))
				.where(fieldName(KEY).cast(String.class)
						.eq(params.getCurrentLevelKey())<commit_msg>Not null condition provided<commit_after>package com.epam.ta.reportportal.dao.widget.healthcheck.query;

import com.epam.ta.reportportal.entity.widget.content.healthcheck.HealthCheckTableGetParams;
import com.google.common.collect.Sets;
import org.jooq.*;
import org.jooq.impl.DSL;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

import static com.epam.ta.reportportal.dao.constant.WidgetContentRepositoryConstants.*;
import static com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName;

/**
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
@Component
public class CustomColumnQueryProvider extends AbstractHealthCheckTableQueryProvider {

	private static final String UNNESTED_ARRAY = "unnested_array";

	public CustomColumnQueryProvider() {
		super(Sets.newHashSet(CUSTOM_COLUMN_SORTING));
	}

	@Override
	protected Select<? extends Record> contentQuery(HealthCheckTableGetParams params, List<Condition> levelConditions) {
		SelectHavingStep<?> selectQuery = DSL.select(DSL.arrayAggDistinct(fieldName(UNNESTED_ARRAY))
				.filterWhere(fieldName(UNNESTED_ARRAY).isNotNull())
				.as(AGGREGATED_VALUES), fieldName(VALUE))
				.from(DSL.table(params.getViewName()), DSL.table(DSL.sql("unnest(?)", fieldName(CUSTOM_COLUMN))).as(UNNESTED_ARRAY))
				.where(fieldName(KEY).cast(String.class)
						.eq(params.getCurrentLevelKey())
{'fraction_non_alphanumeric': 0.12366737739872068, 'fraction_numerical': 0.0, 'mean_word_length': 6.88515406162465, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1798951', 'n_tokens_mistral': 941, 'n_tokens_neox': 910, 'n_words': 124}