title: Query to select data from database between 2 timestamps, Exception: time_bucket function does not exists?
body: <p>I've been trying to write a query in Java to select data from postgres timescale database between 2 timestamps, but I keep getting Exception says that time_bucket function does not exists </p>
  
  <p>I cannot change the timestamp column in database to Date since I dont have the ownership, and I tried to copy paste the query to sql editor, it works perfectly fine!!</p>
  
  <p>this is the query: </p>
  
  <pre><code>private final String SELECT_CANDLESTICK_BY_REQUEST = "SELECT " + 
          "   time_bucket(  interval '1 minute' , period_start_ts) AS periodts,  " + 
          "   count(*),  " + 
          "   first(metrics-&gt;&gt;'askOpen',period_start_ts) as askOpen,  " + 
          "   max(metrics-&gt;&gt;'askHigh') as askHigh,  " + 
          "   min(metrics-&gt;&gt;'askLow') as askLow,  " + 
          "   last(metrics-&gt;&gt;'askClose',period_start_ts) as askClose, " + 
          "   first(metrics-&gt;&gt;'bidOpen',period_start_ts) as bidOpen,  " + 
          "   max(metrics-&gt;&gt;'bidHigh') as bidHigh,  " + 
          "   min(metrics-&gt;&gt;'bidLow') as bidLow,  " + 
          "   last(metrics-&gt;&gt;'bidClose',period_start_ts) as bidClose " + 
          "  FROM candlestick_1_sec_fact " + 
          "  where period_start_ts between ? and ? " + 
          "  and symbol_cd = ? and liquidity_source_nm =  ? " + 
          "  GROUP BY periodts " + 
          "  ORDER BY periodts" ;
  </code></pre>
  
  <p>this is how i set the parameters:</p>
  
  <pre><code>PreparedStatement select = connection.prepareStatement(SELECT_CANDLESTICK_BY_REQUEST);
  
  
      select.setTimestamp(1, new Timestamp(startTime));
      select.setTimestamp(2, new Timestamp(endTime));
      select.setString(3, symbol);
      select.setString(4, source); 
  </code></pre>
  
  <p>this is the exception i get:</p>
  
  <pre><code>org.postgresql.util.PSQLException: ERROR: function time_bucket(interval, timestamp without time zone) does not exist . Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  
  <p>Even if i take out the interval keyword in the query, it still does not recognize the time_bucket function. </p>
  
  <p>Thank you in advance for your time and knowledge!</p>