Search code examples
apache-kafkaksqldb

Could not determine output schema for query due to error: Can't find any functions with the name 'OUNT_DISTINCT'


I am following Confluent KSQLDB tutorials from here: https://www.youtube.com/watch?v=fXJw0jAyn7M&list=PLa7VYi0yPIH3ulxsOf5g43_QiB-HOg5_Y&index=4

I've created topic like below:

kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1  --topic person_stats

Also, I've created

CREATE TABLE PERSON_STATS WITH (VALUE_FORMAT='AVRO') AS 
SELECT PERSON, 
       LATEST_BY_OFFSET(LOCATION) AS LATEST_LOCATION, 
       COUNT(*) AS LOCATION_CHANGES, 
       OUNT_DISTINCT(LOCATION) AS UNIQUE_LOCATIONS 
FROM MOVEMENTS
GROUP BY PERSON
EMIT CHANGES;

Getting below error:

Could not determine output schema for query due to error: Can't find any functions with the name 'OUNT_DISTINCT'
Statement: CREATE TABLE PERSON_STATS WITH (KAFKA_TOPIC='PERSON_STATS', PARTITIONS=1, REPLICAS=1, VALUE_FORMAT='AVRO') AS SELECT
  MOVEMENTS.PERSON PERSON,
  LATEST_BY_OFFSET(MOVEMENTS.LOCATION) LATEST_LOCATION,
  COUNT(*) LOCATION_CHANGES,
  OUNT_DISTINCT(MOVEMENTS.LOCATION) UNIQUE_LOCATIONS
FROM MOVEMENTS MOVEMENTS
GROUP BY MOVEMENTS.PERSON
EMIT CHANGES;
ksql>

Any quick help?


Solution

  • I was able to fix it by using below, works fine

    CREATE TABLE PERSON_STATS WITH (VALUE_FORMAT='AVRO') AS
      SELECT PERSON,
        LATEST_BY_OFFSET(LOCATION) AS LATEST_LOCATION,
        COUNT(*) AS LOCATION_CHANGES,
        COUNT_DISTINCT(LOCATION) AS UNIQUE_LOCATIONS
      FROM MOVEMENTS
    GROUP BY PERSON
    EMIT CHANGES;