Code Monkey home page Code Monkey logo

Comments (7)

cyluss avatar cyluss commented on July 28, 2024

The format string would be %d/%b/%Y:%T %z.

  1. I assume that log source is PostgREST

    # PostgREST logs are structured so we separate timestamp from message using regex

  2. Sample timestamp would be 06/May/2024:08:16:11 -0500 according to PostgREST observability documentation

  3. parse_timestamp function accepts strptime format string and is implemented in Rust chrono crate.

Here is a reproducible example for timestamp parsing:

use chrono::DateTime;
use chrono::offset::FixedOffset;
use chrono::format::ParseError;

fn parse_date(date_str: &str) -> Result<DateTime<FixedOffset>, ParseError> {
    DateTime::parse_from_str(date_str, "%d/%b/%Y:%T %z")
}

fn main() {
    let timestamp = "06/May/2024:08:16:11 -0500";
    println!("Original timestamp: {}", timestamp);
    
    match parse_date(timestamp) {
        Ok(date) => println!("Parsed date: {}", date),
        Err(e) => println!("Failed to parse date: {}", e),
    }
}

which outputs

$ cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/parse-pgrest-timestamp`
Original timestamp: 06/May/2024:08:16:11 -0500
Parsed date: 2024-05-06 08:16:11 -05:00

from supabase.

stefanstidlffg avatar stefanstidlffg commented on July 28, 2024

Thanks for the help.

I forgot to mention that the version of vector I was trying to use is 0.38 while in the master branch we use 0.28.1 here.

Are there any reasons not to upgrade to 0.38? 0.2x version is quite old now.

from supabase.

cyluss avatar cyluss commented on July 28, 2024

@stefanstidlffg Could you change the issue so it matches the issue template? https://github.com/supabase/supabase/issues/new?assignees=&labels=bug&projects=&template=1.Bug_report.md

from supabase.

stefanstidlffg avatar stefanstidlffg commented on July 28, 2024

I don't think it's a bug in the current code. It's just a breaking change if you ever go to vector 0.3x.

I could do a PR with the update to vector 0.38 if you prefer that. But I don't know if anything else is affected by the update.

from supabase.

encima avatar encima commented on July 28, 2024

I have modified the title to reflect the end goal, @stefanstidlffg if you can modify the issue description to follow the template, that would be great. 🙏
feel free to open a PR if anyone does want to tackle this!

from supabase.

stefanstidlffg avatar stefanstidlffg commented on July 28, 2024

I have modified the title to reflect the end goal, @stefanstidlffg if you can modify the issue description to follow the template, that would be great. 🙏
feel free to open a PR if anyone does want to tackle this!

I would if you tell me which template matches the situation. As said before this is not a bug.

from supabase.

cyluss avatar cyluss commented on July 28, 2024

@stefanstidlffg Yes it is not a bug for the current version. But eventually it will break when someone decide to upgrade pgvector and it is not forward compatible. Assuming parse_timestamp is available for current version you could only fix the timestamp parsing code

from supabase.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.